Skip to content

Instantly share code, notes, and snippets.

@matthewglover
Created November 5, 2013 10:09
Show Gist options
  • Save matthewglover/7316721 to your computer and use it in GitHub Desktop.
Save matthewglover/7316721 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'spork'
require 'database_cleaner'
Spork.prefork do
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
RSpec.configure do |config|
config.use_transactional_fixtures = false
config.infer_base_class_for_anonymous_controllers = false
# config.order = "random"
config.before :each do
if Capybara.current_driver == :selenium
DatabaseCleaner.strategy = :truncation
else
DatabaseCleaner.strategy = :transaction
end
DatabaseCleaner.start
end
config.after(:each) do
DatabaseCleaner.clean
end
# Include Factory Girl syntax to simplify calls to factories
config.include FactoryGirl::Syntax::Methods
end
end
Spork.each_run do
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
FactoryGirl.reload
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment