Skip to content

Instantly share code, notes, and snippets.

@mattbrictson
Created May 18, 2012 23:06
Show Gist options
  • Save mattbrictson/2728030 to your computer and use it in GitHub Desktop.
Save mattbrictson/2728030 to your computer and use it in GitHub Desktop.

Revisions

  1. mattbrictson revised this gist May 18, 2012. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions Gemfile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    gem 'database_cleaner', group: :test
  2. mattbrictson created this gist May 18, 2012.
    17 changes: 17 additions & 0 deletions spec_helper.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    RSpec.configure do |config|
    # ...
    config.use_transactional_fixtures = false

    config.before(:each) do
    DatabaseCleaner.strategy = if example.metadata[:js]
    :truncation
    else
    :transaction
    end
    DatabaseCleaner.start
    end

    config.after(:each) do
    DatabaseCleaner.clean
    end
    end