Created
March 21, 2011 04:39
-
-
Save masayoshi/879043 to your computer and use it in GitHub Desktop.
spec_helper for rspec, spork and guard
This file contains hidden or 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
# -*- coding: utf-8 -*- | |
require 'rubygems' | |
require 'spork' | |
Spork.prefork do | |
# Loading more in this block will cause your tests to run faster. However, | |
# if you change any configuration or code from libraries loaded here, you'll | |
# need to restart spork for it take effect. | |
ENV["RAILS_ENV"] ||= 'test' | |
require File.expand_path("../../config/environment", __FILE__) | |
require 'rspec/rails' | |
# Requires supporting files with custom matchers and macros, etc, | |
# in ./support/ and its subdirectories. | |
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f} | |
Rspec.configure do |config| | |
# == Mock Framework | |
# | |
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line: | |
# | |
# config.mock_with :mocha | |
# config.mock_with :flexmock | |
# config.mock_with :rr | |
config.mock_with :rspec | |
config.fixture_path = "#{::Rails.root}/spec/fixtures" | |
# If you're not using ActiveRecord, or you'd prefer not to run each of your | |
# examples within a transaction, comment the following line or assign false | |
# instead of true. | |
config.use_transactional_fixtures = true | |
end | |
ActiveSupport::Dependencies.clear | |
ActiveRecord::Base.instantiate_observers | |
end | |
Spork.each_run do | |
# This code will be run each time you run your specs. | |
# Reload FactoryGirl’s Factories | |
# Factory.factories.clear | |
# Dir[Rails.root.join("spec/factories/**/*.rb")].each{|f| load f} | |
# Reload Routes | |
SampleApp::Application.reload_routes! | |
end | |
# Requires supporting files with custom matchers and macros, etc, | |
# in ./support/ and its subdirectories. | |
# Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment