Mocha loading order

Manfred Stienstra

From version 0.9.8 onwards Mocha wants to be loaded after the test framework. I suspect this has something to do with detecting how to hook into the framework so it can run its expectations.

If you don’t do this, Mocha will not define its methods on the test case or context and you will get a load error:

NoMethodError: undefined method `mock' for #<#<Class>

Note that config.gem immediately loads the gem you’re configuring so you will also have to require those in the correct order:

config.gem 'test-spec'
config.gem 'mocha'

You’re reading an archived weblog post that was originally published on our website.