[rspec-users] before(:all) to set up mocks and stubs

Bayard Randel kit at nocturne.net.nz
Tue Jul 13 18:05:55 EDT 2010

I know that generally it is not considered best practice to user
before(:all) and after(:all) as state is shared between all examples, which
is a unit-testing anti-pattern. The rspec book recommends setting up
fixtures and environment for each example. Perhaps to drive this point home,
support for this method has been dropped in rspec2? (just a guess)
Bayard Randel

On 14 July 2010 00:25, Ivo Dancet <caifara.subscribe at gmail.com> wrote:

> Hi
> I'm upgrading an application to rspec2/rails3. A certain suite of tests,
> that generates a pdf document, uses a before(:all) filter to set the
> environment using mocks and stubs. Then the pdf gets generated and after
> that all the tests run on that same pdf document. In rspec2 it seems like I
> can only use mocks and stubs in in before(:each) filters (thus not in
> before(:all) filters). Has this been changed, or is this supposed to work (I
> may be doing something wrong)?
> Thanks
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20100714/93087aa2/attachment.html>

More information about the rspec-users mailing list