[rspec-devel] mock framework

Zach Dennis zach.dennis at gmail.com
Thu Aug 23 23:00:20 EDT 2007


On 8/23/07, Dan North <dan at tastapod.com> wrote:
>
>  David Chelimsky wrote:
>  On 8/22/07, Scott Taylor <mailing_lists at railsnewbie.com> wrote:
>
>
>  On Aug 22, 2007, at 3:26 PM, Dan North wrote:
>
>
>
>  One potential issue is the one-mocking-framework-per-run
> constraint. In other words, any future development of rspec would
> have to continue to use the rspec mocking framework because we
> couldn't suddenly start using mocha mocks (say) in new examples.
>
> This isn't a big deal for now, but it would be if we started
> wanting to mock things that rspec's built-in mocking framework
> couldn't handle.
>
> However it pans out, we will be implicitly "preferring" whichever
> framework rspec itself uses for describing its own behaviour. Of
> course this would become moot if we could choose a mocking
> framework per describe block (maybe using a stack that gets popped
> at the end of the describe block).
>
>  I believe it's a good option to factor out the mocking framework.
> Why couldn't it just be a dependency on the rspec gem, and use it as
> the default, as it is now? If one wants to use another mocking
> framework, they can - that is the state of things right now (AFAIK).
>
> But I think the docs should be clear about this - that doing bdd w/
> out mocks & stubs shouldn't be an option.
>
> As for using multiple mock frameworks on one project - is that
> currently an option? Couldn't different spec_helper.rb files be
> included for different mocking frameworks?
>
>  The problem w/ mixing mocking frameworks is that some of them (namely
> rspec and mocha) add methods to Object, and they use similar methods
> (like mock()) to create mocks. So you can only safely have one mock
> framework PER PROCESS, not per file.
>
>  I would suggest that you only want one mocking framework per project
> anyway, for the sake of sanity. Surely that comes under common coding
> conventions?!
>
>  Cheers,
>  Dan
>
>

We use two mocking frameworks. Hardmock and Mocha. In some places we
want strict ordered mocks. In other places we don't care and we want
stubbing (which Mocha has and Hardmock doesn't).

They place nice together.

Zach


More information about the rspec-devel mailing list