summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2015-03-04 09:40:03 -0700
committermo khan <mo@mokhan.ca>2015-03-04 09:40:03 -0700
commit0fb2802e11714191c872204f27187a418eb6847b (patch)
tree32751c7632a4a12f36a80d1b724ef5f9036a433d /spec
parentfde3785d7a5d35497481f76f9cec2aa4a835df29 (diff)
add database cleaner.
Diffstat (limited to 'spec')
-rw-r--r--spec/rails_helper.rb2
-rw-r--r--spec/support/database_cleaner.rb21
2 files changed, 22 insertions, 1 deletions
diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb
index b4d9ec7..d93c9ee 100644
--- a/spec/rails_helper.rb
+++ b/spec/rails_helper.rb
@@ -31,7 +31,7 @@ RSpec.configure do |config|
# 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
# RSpec Rails can automatically mix in different behaviours to your tests
# based on their file location, for example enabling you to call `get` and
diff --git a/spec/support/database_cleaner.rb b/spec/support/database_cleaner.rb
new file mode 100644
index 0000000..5083a47
--- /dev/null
+++ b/spec/support/database_cleaner.rb
@@ -0,0 +1,21 @@
+Rspec.configure do |config|
+ 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
+end