Janko,

here is my updated code now.

config.around(:each) do |example|
  if example.metadata[:clean_db_cleaner]
    DatabaseCleaner[:sequel, {connection: @app.database}].cleaning do
      example.run
    end
  else
    @app.database.transaction(:rollback=>:always, :auto_savepoint=>true) {
      example.run
    }
  end
end



So on tests where I need the data in the db, i just add :use_db_cleaner => 
true and it will use databasecleaner, otherwise it uses transactions.


On Saturday, August 29, 2015 at 7:44:59 PM UTC-4, Janko Marohnić wrote:
>
> Note that truncations that you presumably use with DatabaseCleaner are 
> much slower than transactions with rollback. In my personal benchmarks they 
> were 70x slower. This can very quickly add up in your tests, so I suggest 
> you use DatabaseCleaner only if there is no other way.
>
> On Friday, August 28, 2015 at 7:04:41 PM UTC+2, Jon Whitcraft wrote:
>>
>> I found the DatabaseCleaner gem and switched to using that instead of 
>> transactions and resolved my problems.
>>
>> Jon
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to