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:
unexpected invocation: Friendship(id: integer, user_id: integer,
friend_id: integer, status: string, requested_at: datetime,
accepted_at: datetime, created_at: datetime, updated_at:
datetime).is_friend?(#User:0xb6b2bf04, #User:0xb6bc7648)
satisfied expectations:
- expected exactly once, already invoked once: Friendship(id: integer,
user_id: integer, friend_id: integer, status: string, requested_at:
datetime, accepted_at: datetime, created_at: datetime, updated_at:
datetime).is_friend?(#User:0xb6eeb220, #User:0xb6c3a224)
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.
Thanks.