Skip to content

Instantly share code, notes, and snippets.

@panthomakos
Created May 18, 2011 18:41
Show Gist options
  • Save panthomakos/979222 to your computer and use it in GitHub Desktop.
Save panthomakos/979222 to your computer and use it in GitHub Desktop.
Spork, RSpec, Sham and Caching Classes
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
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?
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