[rspec-devel] Specs for problems involving interop with other mocking frameworks

Matt Patterson matt-lists at reprocessed.org
Wed Jan 6 19:32:03 EST 2010

On 6 Jan 2010, at 23:13, David Chelimsky wrote:

> On Wed, Jan 6, 2010 at 1:33 PM, Matt Patterson <matt-lists at reprocessed.org> wrote:
>> Hi all,
>> I'm trying to write a failing spec for a problem which only occurs when mocking under Mocha (and potentially the other non-rspec frameworks) in rspec-rails.
> I saw your lighthouse ticket about this, and I'm a bit confused about what you're trying to achieve. Mocha does not have a should_receive method, so if you're using mocha, you shouldn't expect should_receive to work. Ideally you'd get a NoMethodError on should_receive, but if there's anything that's loading spec/mocks, should_receive will be defined.
> Can you help me understand the use case?

It's specifically to do with RenderObserver in rspec-rails. RenderObserver explicitly defines its own should_receive method, irrespective of the mocking framework you're using to allow you to use controller.should render_template and template.should_receive(:render).with(:partial => 'x'). 

So, my issue was that something which, AFAIK, is supposed to just work whatever mocking framework you're using, is breaking (silently) when you're not using RSpec's own mocks.

My question here was what the best way to run particular rspec-rails specs under several mocking frameworks is. There are already specs which cover the RenderObserver behaviours, they just need running under all the mocking frameworks RSpec supports.


>> I'm not sure what the best way to deal with this is. Ideally, I'd just re-run the existing RenderObserver-related specs in spec/rails/example/view_example_group_spec.rb and the whole spec/rails/matchers/render_template_spec.rb under Mocha, but I'm not sure what the best way to do that is. I mean, I could just `load` the files in and monkey with the config before running them probably through a cuke feature, but that seems kind of icky.
>> Suggestions gratefully received.

  Matt Patterson | Design & Code
  <matt at reprocessed org> | http://www.reprocessed.org/

More information about the rspec-devel mailing list