Skip to content
This repository
tree: 1939b06d5a
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 58 lines (47 sloc) 1.711 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
# -*- encoding : utf-8 -*-
require 'rubygems'

# Standard setup for RSpec
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
require 'webmock/rspec'
  
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
  
RSpec.configure do |config|
  config.mock_with :rspec
  config.fixture_path = "#{::Rails.root}/spec/fixtures"
  config.use_transactional_fixtures = true
  config.infer_base_class_for_anonymous_controllers = true
  
  config.before(:suite) do
    # Speed up testing by deferring garbage collection
    DeferredGarbageCollection.start
    
    # If we're using a memory testing database, load the schema
    if ActiveRecord::Base.connection.class == ActiveRecord::ConnectionAdapters::SQLite3Adapter and
        ActiveRecord::Base.configurations['test']['database'] == ':memory:'
      load_schema = lambda {
        load Rails.root.join('db', 'schema.rb')
      }
      silence_stream(STDOUT, &load_schema)
    end
  end
  
  config.after(:suite) do
    # Clean up GC
    DeferredGarbageCollection.reconsider
  end
  
  config.before(:each) do
    # Disable net connections outbound
    WebMock.enable!
    WebMock.disable_net_connect!(:allow_localhost => true)
    
    # Reset the locale and timezone to defaults on each new test
    I18n.locale = I18n.default_locale
    Time.zone = 'Eastern Time (US & Canada)'
  end
  
  # Add a helper for logging in (and out!) a user, and for breaking
  # the Solr server on demand
  config.extend UserLoginHelper
  config.extend SolrServerHelper
  
  # Skip some tests on JRuby
  if RUBY_PLATFORM == "java"
    config.filter_run_excluding :jruby => false
  end
end
Something went wrong with that request. Please try again.