[rspec-users] Rspec-2 around/before(:all) hooks

Mack T. lists at ruby-forum.com
Wed Nov 3 14:07:25 EDT 2010

I should have mentioned this before, but I'm using fixtures in these
specs.  When I took all of the fixtures out, I get the same before(:all)
behavior that you got.  With them in, it seems whatever happens in the
before(:all) is rolled back before any examples run.  Can you reproduce
that behavior with fixtures included?

What I'm really trying to accomplish here is faster examples that don't
have to repeatedly build the same model relationships.  Doubles won't
work, since I want to make sure models save to the database correctly
and most relationships have foreign key constraints.  It would be great
to establish a known setup of models that all examples can assume

I realize that I'll have to manually undo whatever changes I do in the
before block, but that's a price I'm willing to pay.  Examples should
remain isolated if the database is restored to the same state it was
when they started.

before(:suite) is looking promising.  The instance variables aren't
available as they are in before(:all), but that's simple to work around.

Thank you so much for your help!

Posted via http://www.ruby-forum.com/.

More information about the rspec-users mailing list