summaryrefslogtreecommitdiff
path: root/spec/support/db_cleaner.rb
blob: 33fa2e3fd6f416fe73f0479c17f671af40611d08 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
RSpec.configure do |config|
  config.before(:suite) do
    DatabaseCleaner.strategy = :transaction
    DatabaseRewinder.clean_all
  end

  config.before(:each) do |example|
    unless example.metadata[:js]
      DatabaseCleaner.start
    end
  end

  config.append_after(:each) do |example|
    if example.metadata[:js]
      DatabaseRewinder.clean
    else
      DatabaseCleaner.clean
      DatabaseRewinder.cleaners.each {|c| c.send(:reset) }
    end
  end
end