debian-mirror-gitlab/qa/spec/spec_helper.rb

54 lines
1.5 KiB
Ruby
Raw Normal View History

2019-07-31 22:56:46 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
require_relative '../qa'
2019-03-13 22:55:13 +05:30
require 'rspec/retry'
2017-08-17 22:00:37 +05:30
2019-09-04 21:01:54 +05:30
if ENV['CI'] && QA::Runtime::Env.knapsack? && !ENV['NO_KNAPSACK']
require 'knapsack'
Knapsack::Adapters::RSpecAdapter.bind
end
2019-09-30 21:07:59 +05:30
QA::Runtime::Browser.configure!
QA::Runtime::Scenario.from_env(QA::Runtime::Env.runtime_scenario_attributes) if QA::Runtime::Env.runtime_scenario_attributes
2019-07-07 11:18:12 +05:30
%w[helpers shared_examples].each do |d|
Dir[::File.join(__dir__, d, '**', '*.rb')].each { |f| require f }
end
2018-03-17 18:26:18 +05:30
2017-08-17 22:00:37 +05:30
RSpec.configure do |config|
2019-07-07 11:18:12 +05:30
QA::Specs::Helpers::Quarantine.configure_rspec
2019-03-02 22:35:43 +05:30
2018-12-13 13:39:08 +05:30
config.before do |example|
QA::Runtime::Logger.debug("Starting test: #{example.full_description}") if QA::Runtime::Env.debug?
end
2017-08-17 22:00:37 +05:30
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-03-13 22:55:13 +05:30
# 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-09-04 21:01:54 +05:30
if ENV['CI']
config.around do |example|
2019-10-12 21:52:04 +05:30
retry_times = example.metadata.key?(:quarantine) ? 1 : 2
2019-09-04 21:01:54 +05:30
example.run_with_retry retry: retry_times
end
2019-03-13 22:55:13 +05:30
end
2017-08-17 22:00:37 +05:30
end