What are the pros and cons of rspec mocking against other mocking frameworks?

I saw a lot of outdated podcasts that mention mocha as a gem that I would like to install because it makes the mockery better than rspec. I have the feeling that rspec developers have seized on this and have since improved their mockery. However, in the spec_helper.rb file spec_helper.rb by default I see some commented out code stubs for the three mocking frameworks

  • mocha
  • flexmock
  • rr

Encourage everyone who can give me a decent answer to all the pros and cons in at least one of these frameworks against rspec own mocking structure.

I agree to answer if you can let me break all three against rpsec

+7
ruby frameworks mocking rspec rspec-mocks
source share
2 answers

Indeed, it is just a matter of taste. Take a look at the syntax and play with mocking frameworks to find out what suits you best. Of course, this is the fastest and easiest way to minimize using RSpec's built-in bullying. And, as you mentioned, RSpec developers took signals from other frameworks ... You will find a lot in common between them.

This question has been asked before: see the details there to get an idea of ​​some of the differences (at least between RSpec :: Mock and Mocha).

+3
source share

We used the built-in rspec mocking, until recently, when we switched to mocha. My colleague wrote a blog post about gotchas and a bit about reasoning:
http://developer.newsdesk.se/2010/05/29/migrating-rspec-to-mocha/


Basically, we need the mocha any_instance method, which is useful if you cannot get the instance you want to make fun of. Not a huge advantage, but enough to make it worthy of our time.

+1
source share

All Articles