The latest release of
shoulda-matchers, 1.4.2, now requires Mocha. I’ve been using the RSpec stubbing library, but adding mocha to the project breaks one little part of RSpec stubbing. While Mocha uses
stubs to stub a method and RSpec uses
stub, both use
unstub if you need to unstub a single method. This collision causes problems if you’re using RSpec to create the stub, because the call to
unstub uses Mocha which then promptly fails to remove the RSpec stub!
The solution is to use the RSpec alias
unstub! wherever you need to remove an RSpec stub – since Mocha doesn’t implement
unstub!, you can continue to happily use the RSpec stubbing library and still successfully unstub RSpec stubs.