Skip to content

Instantly share code, notes, and snippets.

@wenzowski
Created October 9, 2011 20:44
Show Gist options
  • Save wenzowski/1274147 to your computer and use it in GitHub Desktop.
Save wenzowski/1274147 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'spork'
require 'simplecov'
SimpleCov.start 'rails'
Spork.prefork do
require "rails/application"
# Prevent Devise from loading the User model super early with it's route hacks for Rails 3.1
# see also: https://github.com/timcharper/spork/wiki/Spork.trap_method-Jujutsu
Spork.trap_method(Rails::Application, :reload_routes!)
Spork.trap_method(Rails::Application::RoutesReloader, :reload!)
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'email_spec'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
RSpec.configure do |config|
config.mock_with :rspec
config.include(EmailSpec::Helpers)
config.include(EmailSpec::Matchers)
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
load "#{Rails.root}/config/routes.rb"
Dir["#{Rails.root}/app/**/*.rb"].each { |f| load f }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment