/
spec_helper.rb
84 lines (64 loc) · 2.22 KB
/
spec_helper.rb
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
ENV["RACK_ENV"] = "test"
require "pry"
require "simplecov"
SimpleCov.start { add_filter "/spec/" }
$LOAD_PATH << File.expand_path("..", __dir__)
$LOAD_PATH << File.expand_path("../lib", __dir__)
# load this first to avoid duplicate constant declaration error
require "logging"
require "rummager"
require "rummager/app" # load the website
require "bundler/setup"
require "climate_control"
require "rack/test"
require "timecop"
require "pry-byebug"
require "govuk_sidekiq/testing"
require "sidekiq/testing/inline" # Make all queued jobs run immediately
require "bunny-mock"
require "govuk_schemas"
# Silence log output
Logging.logger.root.appenders = nil
Sidekiq.logger.level = Logger::WARN
require "webmock/rspec"
require "#{__dir__}/support/default_mappings"
require "#{__dir__}/support/learn_to_rank_explain"
require "#{__dir__}/support/spec_helpers"
require "#{__dir__}/support/schema_helpers"
require "#{__dir__}/support/integration_spec_helper"
require "#{__dir__}/support/index_helpers"
require "gds_api/test_helpers/publishing_api"
RSpec.configure do |config|
config.define_derived_metadata(file_path: %r{/spec/integration/}) do |metadata|
metadata[:tags] ||= []
metadata[:tags] << :integration
end
config.include SpecHelpers
config.include SchemaHelpers
config.include IntegrationSpecHelper, tags: :integration
config.include Rack::Test::Methods, tags: :integration
config.expect_with :rspec do |expectations|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
end
config.mock_with :rspec do |mocks|
mocks.verify_partial_doubles = true
end
config.shared_context_metadata_behavior = :apply_to_host_groups
config.filter_run_when_matching :focus
config.example_status_persistence_file_path = "spec/examples.txt"
config.disable_monkey_patching!
# config.warnings = true
config.before do
# search_config is a global object that has state, while most of the stubbing
# is automatically reset, the index_names or passed into children object and
# cached there.
Cache.clear
Services.cache.clear
end
if config.files_to_run.one?
config.default_formatter = "doc"
end
config.profile_examples = 3
config.order = :random
Kernel.srand config.seed
end