Skip to content

Instantly share code, notes, and snippets.

@manuelmeurer
Created March 12, 2013 16:03
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 manuelmeurer/5144133 to your computer and use it in GitHub Desktop.
Save manuelmeurer/5144133 to your computer and use it in GitHub Desktop.
require 'spork'
Spork.prefork do
require 'sidekiq/testing'
require 'capybara/rails'
require 'capybara/rspec'
require 'draper/test/rspec_integration'
ENV['RAILS_ENV'] ||= 'test'
require 'rails/application'
# Prevent Devise from reloading the routes / loading the user model
Spork.trap_method Rails::Application::RoutesReloader, :reload!
require File.expand_path('../../config/environment', __FILE__)
require 'rspec/rails'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join('spec', 'support', '**', '*.rb')].each { |f| require f }
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.
config.use_transactional_fixtures = true
# Include FactoryGirl syntax methods
config.include FactoryGirl::Syntax::Methods
# Include Devise test helpers in controller specs
config.include Devise::TestHelpers, type: :controller
config.before do
# Clear Rails cache
Rails.cache.clear
# Remove Sidekiq jobs
Sidekiq::Worker.clear_all
end
config.after :all do
# Remove CarrierWave upload and cache folder
FileUtils.rm_rf CarrierWave::Uploader::Base.cache_dir
FileUtils.rm_rf CarrierWave::Uploader::Base.store_dir
end
config.infer_base_class_for_anonymous_controllers = true
config.treat_symbols_as_metadata_keys_with_true_values = true
config.filter_run focus: true
config.run_all_when_everything_filtered = true
end
# Don't make helpers available to decorators by default
Draper::ViewContext.test_strategy :fast
DatabaseCleaner.strategy = :transaction
DatabaseCleaner.clean_with :truncation
end
Spork.each_run do
# Reload ActivityLog to make sure that log_activity method is available in controllers
require 'activity_log'
FactoryGirl.reload
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment