Created
May 18, 2011 18:41
-
-
Save panthomakos/979222 to your computer and use it in GitHub Desktop.
Spork, RSpec, Sham and Caching Classes
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
source 'http://rubygems.org' | |
gem 'rails', '3.0.4' | |
group :test do | |
gem 'database_cleaner' | |
gem 'rspec-rails' | |
gem 'rspec-rails-matchers' | |
gem 'sham' | |
gem 'spork', '=0.9.0.rc7' | |
end |
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 'spork' | |
Spork.prefork do | |
ENV['RAILS_ENV'] ||= 'test' | |
require File.expand_path("../../config/environment", __FILE__) | |
require 'rspec/rails' | |
require 'database_cleaner' | |
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f} | |
RSpec.configure do |config| | |
config.use_transactional_fixtures = false | |
config.use_instantiated_fixtures = false | |
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 | |
ActiveSupport::Dependencies.clear | |
ActiveRecord::Base.instantiate_observers | |
Sham::Config.activate! | |
end if Spork.using_spork? |
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
MyApplication::Application.configure do | |
config.cache_classes = !(ENV['DRB'] == 'true') | |
config.whiny_nils = true | |
config.consider_all_requests_local = true | |
config.action_controller.perform_caching = false | |
config.action_controller.allow_forgery_protection = false | |
config.after_initialize do | |
Sham::Config.activate! | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment