From: Simon Harris <sharris(a)redhat.com>
We were loading seed data at the beginning of each suite then truncating at the
end of each test. This leaves the database with no seed data for all but the
first test in a suite.
Changed this so that seed data is only truncated after each suite to match. The
tests are all transactional anyway so each test is still isolated.
---
src/spec/spec_helper.rb | 13 +++++++------
1 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/src/spec/spec_helper.rb b/src/spec/spec_helper.rb
index 98d7468..3b2d3d2 100644
--- a/src/spec/spec_helper.rb
+++ b/src/spec/spec_helper.rb
@@ -29,24 +29,25 @@ RSpec.configure do |config|
# == Notes
#
# For more information take a look at Spec::Runner::Configuration and Spec::Runner
+
config.before(:each, :type => :controller) do
#activate_authlogic
end
+
config.after(:each, :type => :controller) do
#current_user_session.destroy
end
# Database cleaner
+ DatabaseCleaner.strategy = :truncation
+ DatabaseCleaner.clean_with(:truncation)
+
config.before(:suite) do
- DatabaseCleaner.strategy = :truncation
- DatabaseCleaner.clean_with(:truncation)
- load "#{Rails.root}/db/seeds.rb"
- end
- config.before(:each) do
DatabaseCleaner.start
+ load "#{Rails.root}/db/seeds.rb"
end
- config.after(:each) do
+ config.after(:suite) do
DatabaseCleaner.clean
end
end
--
1.7.4.4