[rspec-users] Global before blocks - filtering by multiple types

Andi Schacke andreas.schacke at gmail.com
Thu Dec 2 05:20:47 EST 2010


Hi

in the config block of rspec I have a before block to reset my
database before each spec:

config.before(:each) {DatabaseCleaner.clean}

I know I can apply this before to a specific type, e.g.

config.before(:each, :type => :model) {DatabaseCleaner.clean}

but what I want to achieve is that the database is cleaned for all
specs except acceptance specs. Is there a way to define this, e.g.
something like:

config.before(:each, :except => :acceptance) {DatabaseCleaner.clean}
or maybe
config.before(:each, :type => [:model, :view, :controller])
{DatabaseCleaner.clean}

Thanks
Andi


More information about the rspec-users mailing list