Skip to content

Instantly share code, notes, and snippets.

@dalpo
Created July 30, 2013 15:44
Show Gist options
  • Save dalpo/6114134 to your computer and use it in GitHub Desktop.
Save dalpo/6114134 to your computer and use it in GitHub Desktop.
transactional_helper for rspec
def without_transactional_fixtures(&block)
self.use_transactional_fixtures = false
before(:all) do
if ENV["RAILS_ENV"].eql? 'test_ci'
DatabaseCleaner.strategy = :truncation
else
DatabaseCleaner.strategy = :truncation
DatabaseCleaner.clean_with(:truncation)
end
end
yield
after(:all) do
if ENV["RAILS_ENV"].eql? 'test_ci'
DatabaseCleaner.strategy = :truncation
else
DatabaseCleaner.strategy = :transaction
DatabaseCleaner.clean_with(:truncation)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment