Skip to content

Instantly share code, notes, and snippets.

@fivetwentysix
Created September 15, 2011 04:35
Show Gist options
  • Save fivetwentysix/1218541 to your computer and use it in GitHub Desktop.
Save fivetwentysix/1218541 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'spork'
Spork.prefork do
ENV["RAILS_ENV"] ||= "test"
require 'cucumber/rails'
require 'factory_girl'
Capybara.default_selector = :css
Capybara.javascript_driver = :webkit
Capybara.default_wait_time = 5
end
Spork.each_run do
FactoryGirl.reload
ActionController::Base.allow_rescue = false
begin
DatabaseCleaner.strategy = :transaction
rescue NameError
raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
end
Before('@no-txn,@selenium,@culerity,@celerity,@javascript') do
DatabaseCleaner.strategy = :truncation, {:except => %w[widgets]}
DatabaseCleaner.start
end
Before('~@no-txn', '~@selenium', '~@culerity', '~@celerity', '~@javascript') do
DatabaseCleaner.strategy = :transaction
end
After('@no-txn,@selenium,@culerity,@celerity,@javascript') do
DatabaseCleaner.clean
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment