Created
October 9, 2011 20:44
-
-
Save wenzowski/1274147 to your computer and use it in GitHub Desktop.
rspec configuration http://stackoverflow.com/questions/7706371/why-does-the-each-iterator-method-break-rspec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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