Skip to content

Mocha should be loaded after Shoulda with rails 2.3

September 22, 2010

Well, this one really drove me crazy. So I decided to finally pen it down. May this help somebody else in future. This might not be very new, but really crazy stuff.

If you are using Mocha and Shoulda both, then please load Mocha after you have loaded Shoulda. Like following:

config.gem “shoulda”, :lib => “shoulda”, :source => “http://gems.github.com”, :version => “>=2.11.3”
config.gem ‘mocha’

If you load Mocha before Shoulda, what happens is that Mocha gets crazy with the expectations. You might see your tests failing because of some weird expectations that are not set in the current failing test but were set somewhere else in some other test.

So, in a nut shell, Mocha starts keeping the expectations across tests instead of wiping them off after each test, as it is expected to do.

Advertisements
One Comment leave one →
  1. Louis permalink
    March 4, 2011 12:30 am

    You just saved me my remaining hair. Still relevant in Rails 3.0

    Many thanks.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: