[rspec-users] Conditional before() blocks in spec_helper based on metadata?

John Feminella johnf at distb.net
Tue Sep 21 09:45:47 EDT 2010


I have some tests that need to load my application's seed data prior
to running, and others that don't. It's a well-defined set of
examples:

    describe "needs seed data", :needs_data => true do
       ...
    end

What can I put in my Rspec.configure { ... } block so that every test
which has ":needs_data => true" will invoke a particular before(:each)
{ ... } block? Note that I still want every test to run; I just want
the :needs_data tests to get some special setup first.

~ jf


More information about the rspec-users mailing list