[rspec-users] stale records with integration testing?
Patrick J. Collins
patrick at collinatorstudios.com
Tue Feb 14 13:02:24 EST 2012
> This could happen for one of two reasons:
>
> 1. The email is already in the database before you run your specs.
>
> To avoid this, use DatabaseCleaner to truncate the tables once before
> each run (not before each example).
>
> 2. Models are generated in before(:all) blocks, which are not
> implicitly wrapped in transactions.
>
> If you generate models in before(:all), then it is your responsibility
> to remove them in an after(:all).
>
> Also - DatabaseCleaner has two modes: transaction and truncation. Make
> sure you're using the appropriate one.
Ah... Ok cool, all of the above info solved my problem.
Thanks!
Patrick J. Collins
http://collinatorstudios.com
More information about the rspec-users
mailing list