|
| 1 | +# frozen_string_literal: true |
| 2 | + |
| 3 | +require 'rspec' |
| 4 | +require 'rspec/its' |
| 5 | +require 'awesome_print' |
| 6 | +require 'colored2' |
| 7 | + |
| 8 | +# frozen_string_literal: true |
| 9 | +RSpec.configure do |config| |
| 10 | + config.expect_with :rspec do |expectations| |
| 11 | + expectations.include_chain_clauses_in_custom_matcher_descriptions = true |
| 12 | + end |
| 13 | + |
| 14 | + config.mock_with :rspec do |mocks| |
| 15 | + mocks.verify_partial_doubles = true |
| 16 | + end |
| 17 | + |
| 18 | + config.shared_context_metadata_behavior = :apply_to_host_groups |
| 19 | + |
| 20 | + config.warnings = true |
| 21 | + config.filter_run_when_matching :focus |
| 22 | + # config.disable_monkey_patching! |
| 23 | + config.order = :random |
| 24 | + Kernel.srand config.seed |
| 25 | +end |
| 26 | + |
| 27 | +if $0 == 'rspec' |
| 28 | + require_relative '../script' |
| 29 | + require_relative '../lib/foo' |
| 30 | + require_relative './script_spec' |
| 31 | + require_relative './lib/foo_spec' |
| 32 | +end |
| 33 | + |
| 34 | +# Sets HOME here because: |
| 35 | +# If otherwise, it causes a runtime failure with the following steps. |
| 36 | +# 1. RSpec::Core::ConfigurationOptions.global_options_file raises an exception |
| 37 | +# because $HOME is not set in the sandbox environment of Bazel |
| 38 | +# 2. the rescue clause calls RSpec::Support.#warning |
| 39 | +# 3. #warning calls #warn_with |
| 40 | +# 4. #warn_with tries to lookup the first caller which is not a part of RSpec. |
| 41 | +# But all the call stack entires are about RSpec at this time because |
| 42 | +# it is invoked by rpsec/autorun. So #warn_with raises an exception |
| 43 | +# 5. The process fails with an unhandled exception. |
| 44 | +# ENV['HOME'] ||= '/' |
0 commit comments