Skip to content

Instantly share code, notes, and snippets.

@hamannp
Created December 6, 2011 19:31
Show Gist options
  • Save hamannp/1439572 to your computer and use it in GitHub Desktop.
Save hamannp/1439572 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'spork'
require 'rspec'
require 'capybara/rspec'
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'
Capybara.javascript_driver = :selenium
end
Spork.each_run do
# This code will be run each time you run your specs.
require 'factory_girl_rails'
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
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
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, remove the following line or assign false
# instead of true.
## Trying to get Capybar to test JS. We need database cleaner below because test transactions
## only work with Rack::Test
config.use_transactional_fixtures = false
config.before(:suite) do
DatabaseCleaner.strategy = :truncation
end
config.before(:each) do
DatabaseCleaner.start
end
config.after(:each) do
DatabaseCleaner.clean
end
end##
end#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment