Skip to content

Instantly share code, notes, and snippets.

@jeffcole
Created November 30, 2015 17:22
Show Gist options
  • Select an option

  • Save jeffcole/8b6d2f7c67aa6d09ce73 to your computer and use it in GitHub Desktop.

Select an option

Save jeffcole/8b6d2f7c67aa6d09ce73 to your computer and use it in GitHub Desktop.
ActiveRecord Spec Helper
# From Rails 4 Test Prescriptions
require 'spec_helper'
require 'active_record'
require 'yaml'
ActiveRecord::Base.establish_connection(
YAML.load_file("config/database.yml")["test"]
)
RSpec.configure do |config|
config.around do |example|
ActiveRecord::Base.transaction do
example.run
raise ActiveRecord::Rollback
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment