Created
June 25, 2012 22:28
-
-
Save KensoDev/2991803 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This file is copied to spec/ when you run 'rails generate rspec:install' | |
ENV["RAILS_ENV"] ||= 'test' | |
require File.expand_path("../../config/environment", __FILE__) | |
require 'rspec/rails' | |
require 'rspec/autorun' | |
# 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| | |
config.infer_base_class_for_anonymous_controllers = false | |
config.filter_run(focus: true) unless ENV['CI_SERVER'] | |
config.run_all_when_everything_filtered = true | |
config.include FactoryGirl::Syntax::Methods | |
# ==========================> Redis test configuration | |
REDIS_PID = "#{Rails.root}/tmp/pids/redis-test.pid" | |
REDIS_CACHE_PATH = "#{Rails.root}/tmp/cache/" | |
config.before(:suite) do | |
DatabaseCleaner.clean_with :truncation | |
end | |
config.before(:each) do | |
if example.metadata[:type] == :request || (example.metadata[:type] == :controller && example.metadata[:file_path][/api\/v[0-9]+/]) || example.metadata[:file_path][/\/integration/] | |
config.use_transactional_fixtures = false | |
DatabaseCleaner.strategy = :truncation | |
else | |
config.use_transactional_fixtures = true | |
DatabaseCleaner.strategy = :transaction | |
Sunspot.session = Sunspot::Rails::StubSessionProxy.new($original_sunspot_session) | |
end | |
if example.metadata[:type] == :request | |
VCR.turn_off! | |
ActiveRecord::Observer.enable_observers | |
else | |
VCR.turn_on! | |
ActiveRecord::Observer.disable_observers | |
end | |
DatabaseCleaner.start | |
end | |
config.after(:each) do | |
DatabaseCleaner.clean | |
Rails.cache.clear | |
$redis.flushdb | |
end | |
config.before :each, solr: true do | |
Sunspot.session = $original_sunspot_session | |
Sunspot.remove_all! | |
end | |
config.mock_with :rspec | |
Capybara.register_driver :selenium do |app| | |
Capybara::Selenium::Driver.new(app, browser: :chrome) | |
end | |
Capybara.default_driver = :selenium | |
Capybara.server_port = 3001 | |
Capybara.app_host = "http://local.gogobot.com:3001" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment