I have the following in my functional test file.
class UserControllerTest < ActionController::TestCase
@controller = UserController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
@invalid_user = userinvalid_user)
@valid_user = usersvalid_user)
When I run a test that tries to use the @valid_user variable I get the
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.
Thanks in advance
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