Skip to content

Instantly share code, notes, and snippets.

@quamen
Created October 1, 2013 00:36
Show Gist options
  • Save quamen/6772378 to your computer and use it in GitHub Desktop.
Save quamen/6772378 to your computer and use it in GitHub Desktop.
Replaces spec_helper.rb when testing ActiveRecord objects.
unless defined?(ActiveRecord)
require "active_record"
require "shoulda-matchers"
dbconfig = YAML::load(File.open("config/database.yml"))
ActiveRecord::Base.establish_connection( dbconfig["test"] )
RSpec.configure do |config|
config.around do |example|
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