i've started writing tests for my controllers. For once of them, i need to be logged in, in order to check whether the page is rendered etc.
Since i'm using Devise that has a current_user helper over a User model, how can i form my :
describe "when it GETS 'town'" do
it "should render the template and be successful" do
get :index
response.should render_template(:index)
response.should be_success
end
end
so that i don't get the undefined "authenticate!" method (devise specific) error ?
There's a good writeup on this topic on the Devise wiki. Basically you need to add the Devise test helpers, then call sign_in
to get a valid current user when your spec expects one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With