On Dec 2, 2010, at 4:20 AM, Andi Schacke wrote:
> 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}
Not exactly, but there is another way:
config.before(:each) do
DatabaseCleaner.clean unless example.metadata[:type] == :acceptance
end
HTH,
David
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users