[rspec-devel] New Stub API Implemented

Brian Takita brian.takita at gmail.com
Fri Sep 29 22:52:31 EDT 2006

What about having listeners on setup and teardown?
For example, a plugin of any nature can register on the setup and teardown
events for each spec.

On 9/29/06, David Chelimsky <dchelimsky at gmail.com> wrote:
> On 9/29/06, James Mead <jamesmead44 at gmail.com> wrote:
> > I've now had requests from several people for a way of using Mocha (&
> > Stubba) without a dependency on Test::Unit so it can interoperate with
> other
> > testing frameworks. Given that this is the reason the current versions
> of
> > Mocha and RSpec don't play together, I thought you might be interested
> to
> > know I'm in the middle of making the necessary (relatively minor)
> changes to
> > make this possible.
> James,
> That's awesome news. Thanks.
> Our plan here is to continue to have an integrated stubbing/mocking
> framework that is invoked by default, but allow other frameworks to be
> plugged in. To make that work most effectively, rspec needs some hook
> into Mocha/Stubba (and vice versa) so that the verification of mocks
> and resetting of stubs is seamless. Here's my current thinking:
> rspec would support a runtime configuration bit that allows users to
> choose a mock framework. Something like this:
> Spec::Mock.plugin = 'mocha'
> In each specification, RSpec includes a module named
> Spec::Mock::Plugin (or something like that) provided by mocha. This
> would provide spec writers access to mocha's API.
> The plugin would have to support two methods for rspec: one to assign
> a mock registry and one to verify a mock. Something like this:
> module Spec
>   module Mock
>     module Plugin
>       attr_writer :mock_registry
>       def verify mock
>         #do whatever mocha does to verify the mock
>         #raise an exception if verification fails
>       end
>       include XXX #module w/ mock creation methods, etc
>     end
>   end
> end
> It would then be mocha's job to call "mock_registry.register mock" as
> each mock is created and rspec's job to call verify(mock) at the end
> of each specification.
> Is this too complex? The thing I like about it is that rspec can make
> a few changes and any framework can offer itself up as a plugin w/
> little effort.
> Thoughts?
> David
> _______________________________________________
> rspec-devel mailing list
> rspec-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-devel/attachments/20060929/8fbd62e0/attachment-0001.html 

More information about the rspec-devel mailing list