Permalink
Browse files

Specs: Use database_cleaner to ensure we start with an empty DB each …

…time
  • Loading branch information...
1 parent ac93c76 commit ebcc111c31c8b538ea4014d36ad6ce88408b355b @etdsoft etdsoft committed Jun 21, 2012
Showing with 15 additions and 1 deletion.
  1. +1 −0 Gemfile
  2. +14 −1 spec/spec_helper.rb
View
@@ -33,6 +33,7 @@ gem 'rubyzip', '~> 0.9.6.1'
gem 'rspec-rails', :group => [:development, :test]
group :test do
+ gem 'database_cleaner'
gem 'factory_girl', '~> 2.6.4'
gem 'capybara'
gem 'guard-rspec'
View
@@ -26,5 +26,18 @@
# 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.strategy = :transaction
+ DatabaseCleaner.clean_with(:truncation)
+ end
+
+ config.before(:each) do
+ DatabaseCleaner.start
+ end
+
+ config.after(:each) do
+ DatabaseCleaner.clean
+ end
end

0 comments on commit ebcc111

Please sign in to comment.