[rspec-users] Mocks: expectations vs spying

David Chelimsky dchelimsky at gmail.com
Tue Oct 21 09:47:55 EDT 2008

On Mon, Oct 20, 2008 at 2:03 AM, Matt Wynne <matt at mattwynne.net> wrote:
> On 19 Oct 2008, at 21:18, Ashley Moran wrote:
>> On Oct 19, 2008, at 9:32 am, Matt Wynne wrote:
>>>> [1] http://notahat.com/not_a_mock
>>> Looks sweet - it will be in my first mock on Monday!
> Thinking about it - how do you use multiple mocking frameworks in a given
> project?
> Is it safe to re-open a Spec::Runner.configure do |config| block at the top
> of an individual spec after I've loaded spec_helper (which will have to be
> configured to use the default rspec mocking that 90% of the project uses)?

Not really. The problem is that examples are stored for evaluation
later, whereas the configuration is evaluated right away.

The reason rspec won't support using multiple mock frameworks is rspec
mocks and mocha both extend Object (to support mock behaviour on real
objects) and they use the same methods to create instances of mocks.

I think that if we wanted to support multiple mock frameworks, all of
the frameworks would have to offer an explicit mode where you could
extend objects to behave like mocks but would have to do so explicitly
for each object. Flexmock already works this way.


> cheers,
> Matt
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

More information about the rspec-users mailing list