Mocha expectation is affecting (bleeding) from one test to another:
In one test, I have:
Friendship.expects(:is_friend?).with(users[1], users[3]).returns(true)
Then, in another test, which actually is listed before the test, I am
getting this error:
What's going on? I am not using test-unit gem, or shoulda. I removed
'require 'mocha' from the top of the test file but the problem remains
the same. Interestingly, it doesn't happen on my Mac machine. It
only happens on my staging server which is Ubuntu. I am on rails
2.3.5.
I realise this probably won't help you directly because you state that
you're not using shoulda but I had a similar problem with mocha stubs
bleeding from one Shoulda test to another.
I found that reversing the order of the config.gem lines in
environment.rb, thus:
config.gem "thoughtbot-shoulda", :lib => "shoulda" #- shoulda must
be loaded before mocha
config.gem "mocha" #--or
any_instance bleeds between tests
resolved the problem. I didn't investigate why.
Also, this problem didn't seem to occur when I ran under autotest. It
only popped up when running the tests with rake. I expect because
autotest runs the tests as separate processes.