Skip to content

Instantly share code, notes, and snippets.

@regedarek
Created October 7, 2012 01:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save regedarek/980fed2e82aadf566291 to your computer and use it in GitHub Desktop.
Save regedarek/980fed2e82aadf566291 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'spork'
Spork.prefork do
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'webmock/rspec'
require "shoulda/matchers" # Explicitly including shoulda-matchers after rspec
# require 'rspec/autorun' # check if that is necessary
require 'factory_girl_rails'
require 'pry-remote'
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
RSpec.configure do |config|
config.mock_with :rspec
config.use_transactional_fixtures = false
config.include LoginHelper, :type => :controller
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation)
end
config.before do
# default strategy
DatabaseCleaner.strategy = :transaction
end
config.before :truncation => true do
DatabaseCleaner.strategy = :truncation
end
config.before type: :request do
# use truncation for request specs because we are running in two processes
DatabaseCleaner.strategy = :truncation
Resque.inline = true
end
config.before do
DatabaseCleaner.start
WebMock.disable_net_connect!(:allow_localhost => true)
end
config.after do
DatabaseCleaner.clean
Resque.inline = false
end
config.infer_base_class_for_anonymous_controllers = false
config.include FactoryGirl::Syntax::Methods
config.filter_run :focus => true
config.run_all_when_everything_filtered = true
config.treat_symbols_as_metadata_keys_with_true_values = true
end
end
Spork.each_run do
load "#{Rails.root}/config/routes.rb"
FactoryGirl.reload
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment