debian-mirror-gitlab/spec/support/rspec.rb

60 lines
2 KiB
Ruby
Raw Permalink Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2022-10-11 01:57:18 +05:30
require_relative "rspec_order"
require_relative "system_exit_detected"
2018-10-15 14:42:47 +05:30
require_relative "helpers/stub_configuration"
2018-11-18 11:00:15 +05:30
require_relative "helpers/stub_metrics"
2018-10-15 14:42:47 +05:30
require_relative "helpers/stub_object_storage"
require_relative "helpers/stub_env"
2020-07-28 23:09:34 +05:30
require_relative "helpers/fast_rails_root"
2021-01-29 00:20:46 +05:30
2023-03-04 22:38:38 +05:30
require_relative "../../lib/gitlab/utils"
2022-07-16 23:28:13 +05:30
RSpec::Expectations.configuration.on_potential_false_positives = :raise
2018-10-15 14:42:47 +05:30
RSpec.configure do |config|
2023-01-13 00:05:48 +05:30
# See https://gitlab.com/gitlab-org/gitlab/-/issues/379686
config.threadsafe = false
2022-10-11 01:57:18 +05:30
# Re-run failures locally with `--only-failures`
config.example_status_persistence_file_path = ENV.fetch('RSPEC_LAST_RUN_RESULTS_FILE', './spec/examples.txt')
2023-05-27 22:25:52 +05:30
# Makes diffs show entire non-truncated values.
config.before(:each, :unlimited_max_formatted_output_length) do
config.expect_with :rspec do |c|
c.max_formatted_output_length = nil
end
end
2022-10-11 01:57:18 +05:30
unless ENV['CI']
# Allow running `:focus` examples locally,
# falling back to all tests when there is no `:focus` example.
config.filter_run focus: true
config.run_all_when_everything_filtered = true
end
2022-01-26 12:08:38 +05:30
config.mock_with :rspec do |mocks|
mocks.verify_doubled_constant_names = true
end
2018-10-15 14:42:47 +05:30
config.raise_errors_for_deprecations!
config.include StubConfiguration
2018-11-18 11:00:15 +05:30
config.include StubMetrics
2018-10-15 14:42:47 +05:30
config.include StubObjectStorage
config.include StubENV
2020-07-28 23:09:34 +05:30
config.include FastRailsRoot
2023-03-04 22:38:38 +05:30
warn_missing_feature_category = Gitlab::Utils.to_boolean(ENV['RSPEC_WARN_MISSING_FEATURE_CATEGORY'], default: true)
# Add warning for example missing feature_category
config.before do |example|
if warn_missing_feature_category && example.metadata[:feature_category].blank? && !ENV['CI']
2023-07-09 08:55:56 +05:30
location =
example.metadata[:shared_group_inclusion_backtrace].last&.formatted_inclusion_location ||
example.location
warn "Missing metadata feature_category: #{location} See https://docs.gitlab.com/ee/development/testing_guide/best_practices.html#feature-category-metadata"
2023-03-04 22:38:38 +05:30
end
end
2018-10-15 14:42:47 +05:30
end