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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
require 'rails/all'
require 'warning'
Warning.ignore([:not_reached, :unused_var], /.*vendor_ruby\/mail\/parser.*/)
module RSpecRails
class Application < ::Rails::Application
config.secret_key_base = 'ASecretString'
if defined?(ActionCable)
ActionCable.server.config.cable = { "adapter" => "test" }
ActionCable.server.config.logger =
ActiveSupport::TaggedLogging.new ActiveSupport::Logger.new(StringIO.new)
end
end
def self.world
@world
end
def self.world=(world)
@world = world
end
end
I18n.enforce_available_locales = true
require 'rspec/support/spec'
require 'rspec/core/sandbox'
require 'rspec/matchers/fail_matchers'
require 'rspec/rails'
#require 'ammeter/init'
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
class RSpec::Core::ExampleGroup
def self.run_all(reporter = nil)
run(reporter || RSpec::Mocks::Mock.new('reporter').as_null_object)
end
end
# This behaviour will become the default in Rails 8, for now it silences a deprecation
if ActiveSupport.respond_to?(:to_time_preserves_timezone)
ActiveSupport.to_time_preserves_timezone = true
end
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
RSpec.configure do |config|
# Bring in the failure matchers from rspec-expectations
config.include RSpec::Matchers::FailMatchers
config.expect_with :rspec do |expectations|
# include_chain_clauses_in_custom_matcher_descriptions is removed in RSpec Expectations 4
expectations.include_chain_clauses_in_custom_matcher_descriptions = true if expectations.respond_to?(:include_chain_clauses_in_custom_matcher_descriptions=)
expectations.max_formatted_output_length = 1000
end
config.mock_with :rspec do |mocks|
mocks.verify_partial_doubles = true
mocks.verify_doubled_constant_names = true
end
config.filter_run_when_matching :focus
config.order = :random
Kernel.srand config.seed
# shared_context_metadata_behavior is removed in RSpec 4
config.shared_context_metadata_behavior = :apply_to_host_groups if config.respond_to?(:shared_context_metadata_behavior=)
# Zero monkey patching mode is the default and only mode in RSpec 4
config.disable_monkey_patching! if config.respond_to?(:disable_monkey_patching!)
config.warnings = true
config.raise_on_warning = true
# Execute a provided block with RSpec global objects (configuration,
# world, current example) reset. This is used to test specs with RSpec.
config.around(:example) do |example|
RSpec::Core::Sandbox.sandboxed do |sandbox_config|
# If there is an example-within-an-example, we want to make sure the inner
# example does not get a reference to the outer example (the real spec) if
# it calls something like `pending`.
sandbox_config.before(:context) { RSpec.current_example = nil }
RSpec::Rails.initialize_configuration(sandbox_config)
example.run
end
end
end
|