2019-04-11 08:02:24 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-02-20 06:45:04 -05:00
|
|
|
require_relative '../qa'
|
2019-02-19 07:12:07 -05:00
|
|
|
require 'rspec/retry'
|
2020-08-20 23:10:16 -04:00
|
|
|
require 'rspec-parameterized'
|
2017-02-20 06:45:04 -05:00
|
|
|
|
2019-06-03 06:37:43 -04:00
|
|
|
if ENV['CI'] && QA::Runtime::Env.knapsack? && !ENV['NO_KNAPSACK']
|
|
|
|
require 'knapsack'
|
|
|
|
Knapsack::Adapters::RSpecAdapter.bind
|
|
|
|
end
|
|
|
|
|
2019-07-09 11:40:46 -04:00
|
|
|
QA::Runtime::Browser.configure!
|
|
|
|
|
|
|
|
QA::Runtime::Scenario.from_env(QA::Runtime::Env.runtime_scenario_attributes) if QA::Runtime::Env.runtime_scenario_attributes
|
|
|
|
|
2020-09-02 11:10:54 -04:00
|
|
|
Dir[::File.join(__dir__, "support/helpers/*.rb")].sort.each { |f| require f }
|
|
|
|
Dir[::File.join(__dir__, "support/shared_contexts/*.rb")].sort.each { |f| require f }
|
|
|
|
Dir[::File.join(__dir__, "support/shared_examples/*.rb")].sort.each { |f| require f }
|
2018-01-23 05:23:23 -05:00
|
|
|
|
2017-02-20 06:45:04 -05:00
|
|
|
RSpec.configure do |config|
|
2019-03-11 07:50:09 -04:00
|
|
|
QA::Specs::Helpers::Quarantine.configure_rspec
|
2018-12-28 07:15:32 -05:00
|
|
|
|
2019-02-13 23:35:20 -05:00
|
|
|
config.before do |example|
|
2019-12-09 04:08:00 -05:00
|
|
|
QA::Runtime::Logger.debug("\nStarting test: #{example.full_description}\n")
|
2018-10-02 14:31:39 -04:00
|
|
|
end
|
|
|
|
|
2019-10-31 05:06:29 -04:00
|
|
|
config.after(:context) do
|
|
|
|
if !QA::Runtime::Browser.blank_page? && QA::Page::Main::Menu.perform(&:signed_in?)
|
|
|
|
QA::Page::Main::Menu.perform(&:sign_out)
|
|
|
|
raise(
|
|
|
|
<<~ERROR
|
|
|
|
The test left the browser signed in.
|
|
|
|
|
|
|
|
Usually, Capybara prevents this from happening but some things can
|
|
|
|
interfere. For example, if it has an `after(:context)` block that logs
|
|
|
|
in, the browser will stay logged in and this will cause the next test
|
|
|
|
to fail.
|
|
|
|
|
|
|
|
Please make sure the test does not leave the browser signed in.
|
|
|
|
ERROR
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-02-20 06:45:04 -05:00
|
|
|
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.disable_monkey_patching!
|
|
|
|
config.expose_dsl_globally = true
|
|
|
|
config.profile_examples = 10
|
|
|
|
config.order = :random
|
|
|
|
Kernel.srand config.seed
|
2019-02-19 07:12:07 -05:00
|
|
|
|
|
|
|
# show retry status in spec process
|
|
|
|
config.verbose_retry = true
|
|
|
|
|
|
|
|
# show exception that triggers a retry if verbose_retry is set to true
|
|
|
|
config.display_try_failure_messages = true
|
|
|
|
|
2019-12-03 04:09:09 -05:00
|
|
|
if ENV['CI'] && !QA::Runtime::Env.disable_rspec_retry?
|
2020-04-02 20:07:49 -04:00
|
|
|
non_quarantine_retries = QA::Runtime::Env.ci_project_name =~ /staging|canary|production/ ? 3 : 2
|
2019-05-06 22:49:39 -04:00
|
|
|
config.around do |example|
|
2020-04-02 20:07:49 -04:00
|
|
|
retry_times = example.metadata.key?(:quarantine) ? 1 : non_quarantine_retries
|
2019-05-06 22:49:39 -04:00
|
|
|
example.run_with_retry retry: retry_times
|
|
|
|
end
|
2019-02-19 07:12:07 -05:00
|
|
|
end
|
2017-02-20 06:45:04 -05:00
|
|
|
end
|