samedi 20 août 2016

Disabling database_cleaner in specific spec - Rails, database_cleaner

Is there a way to disable database_cleaner gem inside a specific spec? I am using the standard config:

...
require 'database_cleaner'

RSpec.configure do |config|
  config.before(:suite) do
    DatabaseCleaner.strategy = :truncation
    DatabaseCleaner.clean_with(:truncation)
  end
  config.around(:each) do |example|
    DatabaseCleaner.cleaning do
      example.run
    end
  end
end
...

I know that I can switch to before(:all) hooks for each spec but I feel that there has to be a way add an exception for a specific example.

Aucun commentaire:

Enregistrer un commentaire