views:

94

answers:

0

When I run my functional tests one by one they pass with no problems. However when I run them via rake test:functionals several individual tests fail with the same error.

The error is as follows

NoMethodError: You have a nil object when you didn't expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.[]
authlogic (2.1.5) lib/authlogic/controller_adapters/rails_adapter.rb:18:in `cookie_domain'
    authlogic (2.1.5) lib/authlogic/session/cookies.rb:125:in `destroy_cookie'
    authlogic (2.1.5) lib/authlogic/session/callbacks.rb:83:in `after_destroy'
    authlogic (2.1.5) lib/authlogic/session/existence.rb:50:in `destroy'
    app/controllers/application_controller.rb:80:in `prevent_user_acting_as_other_user'
    /test/functional/sentences_controller_test.rb:442:in `__bind_1276126089_810487'
    /Library/Ruby/Gems/1.8/gems/thoughtbot-shoulda-2.10.2/lib/shoulda/context.rb:369:in `call'
    /Library/Ruby/Gems/1.8/gems/thoughtbot-shoulda-2.10.2/lib/shoulda/context.rb:369:in `run_current_setup_blocks'
    /Library/Ruby/Gems/1.8/gems/thoughtbot-shoulda-2.10.2/lib/shoulda/context.rb:368:in `each'
    /Library/Ruby/Gems/1.8/gems/thoughtbot-shoulda-2.10.2/lib/shoulda/context.rb:368:in `run_current_setup_blocks'
    /Library/Ruby/Gems/1.8/gems/thoughtbot-shoulda-2.10.2/lib/shoulda/context.rb:350:in `test: on trying to POST a sentence with another Users ID should not change the number of sentences. '
    /Applications/RubyMine 2.0.2.app/rb/testing/patch/testunit/test/unit/ui/testrunnermediator.rb:36:in `run_suite'
    /Applications/RubyMine 2.0.2.app/rb/testing/patch/testunit/test/unit/ui/teamcity/testrunner.rb:215:in `start_mediator'
    /Applications/RubyMine 2.0.2.app/rb/testing/patch/testunit/test/unit/ui/teamcity/testrunner.rb:191:in `start'

and this line of code seems to be a common cause

@current_user_session.destroy

It seems its something to do with authlogic and cookies. but I dont understand why these same tests when when ran individually pass.

Can anyone give me some pointers where to look?