Skip to content

Instantly share code, notes, and snippets.

@jschoolcraft
Forked from felipeelias/spec_helper.rb
Created January 10, 2013 00:53
Show Gist options
  • Save jschoolcraft/4498442 to your computer and use it in GitHub Desktop.
Save jschoolcraft/4498442 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.execute("TRUNCATE #{ActiveRecord::Base.connection.tables.join(',')} RESTART IDENTITY")
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