Skip to content

Instantly share code, notes, and snippets.

@dpmccabe
Created August 6, 2012 22:34
Show Gist options
  • Save dpmccabe/3279090 to your computer and use it in GitHub Desktop.
Save dpmccabe/3279090 to your computer and use it in GitHub Desktop.
require 'spork'
Spork.prefork do
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'capybara/rspec'
require 'database_cleaner'
Spork.trap_method(Rails::Application, :reload_routes!)
Spork.trap_method(Rails::Application::RoutesReloader, :reload!)
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
RSpec.configure do |config|
config.mock_with :rspec
config.use_transactional_fixtures = false
config.include Devise::TestHelpers, type: :controller
config.include FactoryGirl::Syntax::Methods
# config.include(MailerSupport)
config.filter_run focus: true
config.run_all_when_everything_filtered = true
config.filter_run_excluding ignore: true
config.before(:suite) do
DatabaseCleaner.strategy = :transaction
DatabaseCleaner.clean_with(:truncation)
end
config.before(:each) do
DatabaseCleaner.start
end
config.after(:each) do
DatabaseCleaner.clean
end
end
end
Spork.each_run do
FactoryGirl.reload
Dir["#{Rails.root}/app/models/**/*.rb"].each { |model| require model }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment