I'm a Rails beginner working through Michael Hartl's Rails Tutorial and am receiving an error I have no idea how to fix. For reference, this is for implementing the changes in listing 9.24 (http://ift.tt/2sHvEFW).
I skipped chapter 9 (since it is supposedly optional) but in Chapter 10 it asks to include the changes made in listing 9.24.
This is the error I am recieving when I run rails test
Error:
UsersEditTest#test_unsuccessful_edit:
NoMethodError: undefined method `session' for nil:NilClass
test/test_helper.rb:18:in `log_in_as'
test/integration/users_edit_test.rb:14:in `block in <class:UsersEditTest>'
bin/rails test test/integration/users_edit_test.rb:12
E
Error:
UsersEditTest#test_successful_edit:
NoMethodError: undefined method `session' for nil:NilClass
test/test_helper.rb:18:in `log_in_as'
test/integration/users_edit_test.rb:28:in `block in <class:UsersEditTest>'
The tests (in test/integration/users_edit_test.rb) that are failing are:
test "successful edit" do
log_in_as(@user)
get edit_user_path(@user)
... end
test "unsuccessful edit" do
log_in_as(@user)
get edit_user_path(@user)
... end
and here is the integration/test_helper method that is being called
# Log in as a particular user.
def log_in_as(user)
session[:user_id] = user.id
end
What is especially confusing is that there is another method in the test helper that also uses sessions, and is called in user_login_test which works fine.
Any help would be greatly appreciated!!
Aucun commentaire:
Enregistrer un commentaire