I have the following in my functional test file.
class UserControllerTest < ActionController::TestCase
fixtures :users
def setup
@controller = UserController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
@invalid_user = userinvalid_user)
@valid_user = usersvalid_user)
end
def test_login_success
@valid_user.screen_name
end
When I run a test that tries to use the @valid_user variable I get the
following error.
NoMethodError: You have a nil object when you didn't expect it!
The error occurred while evaluating nil.screen_name
It seems that this class isn't storing the instance variables in memory.
Any ideas.
Thanks in advance
Mitch
I just found the answer. Cryptic little bugger.
t's worth noting that R2.0.2 subclasses ActionController::TestCase
for functional tests (i.e. UserControllerTest), not
ActiveSupport::TestCase. You need to explicitly change the skeleton
test files for (user|spec|etc)_controller_test.rb files to subclass
ActiveSupport::TestCase.


invalid_user)





Bookmarks