I wanna test my functionals in my rails application, but the tests require a user/admin to be logged in. I have looked at many websites, but I cannot grasp what I really should be doing to make it work. I’m sure there there is an easy thing to do, but I cannot seem to find it.
I have seen the stubs command used, but I only get that it is an undefined method and I don’t really know what it is supposed to do.
Any ideas on how I can run my tests as if it was an user/admin requesting them?
Thanks for any help I might get.
acceptance/integration testing:
If you’re using cucumber, just login as the user. Something like:
fill_in ‘users[username]’, :with => “my username”
fill_in ‘users[password]’, :with => “my password”
click_button “Log In”
If you’re using rspec+capybara, you can do something like this (assuming you’re using Devise for authentication)
unit testing
sessionobject, or by stubbing outcurrent_user(assuming you call it that)