[rspec-users] Mocks: expectations vs spying

David Chelimsky dchelimsky at gmail.com
Tue Oct 21 12:01:35 EDT 2008


On Tue, Oct 21, 2008 at 10:41 AM, Matt Wynne <matt at mattwynne.net> wrote:
> So if I want to have a spec suite which uses a combination of mocking
> frameworks, is this possible?
>
> Maybe if some of the files include ../not_a_mock_spec_helper and the others
> include ../default_spec_helper and then both those files require some common
> spec_helper file?

That could work - but the conflict I described is a process-wide
conflict - so you'd need to run the examples in those dirs w/ separate
rake tasks to really eliminate the conflict.

>
> On 21 Oct 2008, at 14:47, David Chelimsky wrote:
>
>> 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.
>>
>> FWIW,
>> David
>>
>>>
>>> cheers,
>>> Matt
>>> _______________________________________________
>>> rspec-users mailing list
>>> rspec-users at rubyforge.org
>>> http://rubyforge.org/mailman/listinfo/rspec-users
>>>
>> _______________________________________________
>> rspec-users mailing list
>> rspec-users at rubyforge.org
>> http://rubyforge.org/mailman/listinfo/rspec-users
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list