Skip to content

Instantly share code, notes, and snippets.

@dgilperez
Forked from felipeelias/spec_helper.rb
Last active December 10, 2015 18:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dgilperez/4475297 to your computer and use it in GitHub Desktop.
Save dgilperez/4475297 to your computer and use it in GitHub Desktop.
RSpec.configure do |config|
config.around do |example|
# For examples using capybara-webkit for example.
# Remove this if you don't use it or anything similar
if example.metadata[:js]
example.run
ActiveRecord::Base.connection.tables.each do |table|
ActiveRecord::Base.connection.execute("TRUNCATE TABLE #{table};")
end
else
ActiveRecord::Base.transaction do
example.run
raise ActiveRecord::Rollback
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment