Skip to content

Commit

Permalink
Merge pull request #1105 from sul-dlss/add-db-cleaner
Browse files Browse the repository at this point in the history
Add database cleaner and implement in spec helper.
  • Loading branch information
Laney McGlohon committed Nov 11, 2015
2 parents 358e4f3 + 0dfb054 commit 745ff5e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ end
group :development, :test do
gem 'rspec-rails', '< 2.99'
gem 'capybara'
# We use database cleaner to empty out the database between tests (see spec_helper for usage)
gem 'database_cleaner'
gem 'poltergeist'
end

Expand Down
4 changes: 3 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ GEM
thor
css_parser (1.3.5)
addressable
database_cleaner (1.5.1)
deprecation (0.1.0)
activesupport
devise (3.2.4)
Expand Down Expand Up @@ -358,6 +359,7 @@ DEPENDENCIES
capybara
coderay
coveralls
database_cleaner
deprecation
devise
devise-guests
Expand Down Expand Up @@ -396,4 +398,4 @@ DEPENDENCIES
whenever

BUNDLED WITH
1.10.4
1.10.6
22 changes: 21 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,27 @@
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = true
config.use_transactional_fixtures = false

config.before(:suite) do
DatabaseCleaner.clean_with(:truncation)
end

config.before(:each) do
DatabaseCleaner.strategy = :transaction
end

config.before(:each, js: true) do
DatabaseCleaner.strategy = :truncation
end

config.before(:each) do
DatabaseCleaner.start
end

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

# If true, the base class of anonymous controllers will be inferred
# automatically. This will be the default behavior in future versions of
Expand Down

0 comments on commit 745ff5e

Please sign in to comment.