Incompatibility in behaviour of "rake test" and "ruby -Itest


#1

Hello everybody,

I had a following problem today. My test that I used to run successfully
with “ruby -Itest” is failing when it is run with “rake
test:integration”.
I can’t understand why.

Could you please check below the test class definition and output that
“ruby -Itest” and “rake test:integration” give me.

Thank you in advance,
Evgeny

class ActorChatSpacesTest < ActionController::IntegrationTest
fixtures :actors, :spaces, :invitations, :roles

def test_actor_chats
actor = actors(:Christophe)
chats = []
chat_spaces = Space.get_chat_spaces()
chat_spaces.each do |chat_space|
if chat_space.actors.include?(actor)
chats = chats << chat_space
end
end
assert actor.chats.eql?(chats)
end
end

$ruby -Itest test/integration/actor_chat_spaces_test.rb
Loaded suite test/integration/actor_chat_spaces_test
Started

Finished in 0.160407 seconds.

2 tests, 2 assertions, 0 failures, 0 errors

$ rake test:integration
(in /Users/assistants/workspace/elogbook/trunk)
/opt/local/bin/ruby -Ilib:test
“/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake/rake_test_loader.rb”
“test/integration/actor_chat_spaces_test.rb”
“test/integration/space_chat_model_test.rb”
Loaded suite
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake/rake_test_loader
Started
E…
Finished in 0.183948 seconds.

  1. Error:
    test_actor_chats(ActorChatSpacesTest):
    NoMethodError: You have a nil object when you didn’t expect it!
    You might have expected an instance of Array.
    The error occurred while evaluating nil.each
    ./test/integration/actor_chat_spaces_test.rb:15:in
    test_actor_chats' /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/testing/setup_and_teardown.rb:67:insend
    /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/testing/setup_and_teardown.rb:67:in
    run' /opt/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/integration.rb:600:inrun’

6 tests, 13 assertions, 0 failures, 1 errors
rake aborted!
Command failed with status (1): [/opt/local/bin/ruby -Ilib:test
"/opt/local…]

(See full trace by running task with --trace)