Results 1 to 3 of 3
Apr 6, 2009, 07:04 #1
- Join Date
- Mar 2009
- 0 Post(s)
- 0 Thread(s)
instance variables and test functionals
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
Last edited by mitchai; Apr 6, 2009 at 07:14. Reason: found the answer