Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/qa/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-09-20 16:18:24 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-09-20 16:18:24 +0300
commit0653e08efd039a5905f3fa4f6e9cef9f5d2f799c (patch)
tree4dcc884cf6d81db44adae4aa99f8ec1233a41f55 /qa/spec
parent744144d28e3e7fddc117924fef88de5d9674fe4c (diff)
Add latest changes from gitlab-org/gitlab@14-3-stable-eev14.3.0-rc42
Diffstat (limited to 'qa/spec')
-rw-r--r--qa/spec/git/repository_spec.rb2
-rw-r--r--qa/spec/page/logging_spec.rb1
-rw-r--r--qa/spec/qa_deprecation_toolkit_env.rb2
-rw-r--r--qa/spec/resource/base_spec.rb2
-rw-r--r--qa/spec/runtime/api/client_spec.rb2
-rw-r--r--qa/spec/runtime/env_spec.rb2
-rw-r--r--qa/spec/runtime/namespace_spec.rb2
-rw-r--r--qa/spec/runtime/release_spec.rb19
-rw-r--r--qa/spec/spec_helper.rb21
-rw-r--r--qa/spec/specs/allure_report_spec.rb7
-rw-r--r--qa/spec/specs/helpers/context_selector_spec.rb4
-rw-r--r--qa/spec/specs/helpers/quarantine_spec.rb4
-rw-r--r--qa/spec/specs/parallel_runner_spec.rb2
-rw-r--r--qa/spec/support/formatters/allure_metadata_formatter_spec.rb (renamed from qa/spec/support/allure_metadata_formatter_spec.rb)5
-rw-r--r--qa/spec/support/formatters/test_stats_formatter_spec.rb171
-rw-r--r--qa/spec/support/helpers/stub_env.rb42
-rw-r--r--qa/spec/support/matchers/eventually_matcher.rb133
-rw-r--r--qa/spec/support/matchers/have_matcher.rb30
-rw-r--r--qa/spec/support/matchers/have_text.rb48
-rw-r--r--qa/spec/support/repeater_spec.rb2
-rw-r--r--qa/spec/support/retrier_spec.rb3
-rw-r--r--qa/spec/support/waiter_spec.rb2
22 files changed, 196 insertions, 310 deletions
diff --git a/qa/spec/git/repository_spec.rb b/qa/spec/git/repository_spec.rb
index 77639c54b79..6b100f9dc16 100644
--- a/qa/spec/git/repository_spec.rb
+++ b/qa/spec/git/repository_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe QA::Git::Repository do
- include Helpers::StubENV
+ include QA::Support::Helpers::StubEnv
shared_context 'unresolvable git directory' do
let(:repo_uri) { 'http://foo/bar.git' }
diff --git a/qa/spec/page/logging_spec.rb b/qa/spec/page/logging_spec.rb
index 3e1011dcd2a..7c521f60b84 100644
--- a/qa/spec/page/logging_spec.rb
+++ b/qa/spec/page/logging_spec.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
require 'capybara/dsl'
-require 'logger'
RSpec.describe QA::Support::Page::Logging do
let(:page) { double.as_null_object }
diff --git a/qa/spec/qa_deprecation_toolkit_env.rb b/qa/spec/qa_deprecation_toolkit_env.rb
index cdd5d954b20..2a21961d89e 100644
--- a/qa/spec/qa_deprecation_toolkit_env.rb
+++ b/qa/spec/qa_deprecation_toolkit_env.rb
@@ -12,7 +12,7 @@ module QaDeprecationToolkitEnv
end
def self.configure!
- # Enable ruby deprecations for keywords, it's suppressed by default in Ruby 2.7.2
+ # Enable ruby deprecations for keywords, it's suppressed by default in Ruby 2.7
Warning[:deprecated] = true
DeprecationToolkit::Configuration.test_runner = :rspec
diff --git a/qa/spec/resource/base_spec.rb b/qa/spec/resource/base_spec.rb
index c6dd56b5f47..b24ced9e310 100644
--- a/qa/spec/resource/base_spec.rb
+++ b/qa/spec/resource/base_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe QA::Resource::Base do
- include Helpers::StubENV
+ include QA::Support::Helpers::StubEnv
let(:resource) { spy('resource') }
let(:location) { 'http://location' }
diff --git a/qa/spec/runtime/api/client_spec.rb b/qa/spec/runtime/api/client_spec.rb
index 36ee563de39..c8439df3b35 100644
--- a/qa/spec/runtime/api/client_spec.rb
+++ b/qa/spec/runtime/api/client_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe QA::Runtime::API::Client do
- include Helpers::StubENV
+ include QA::Support::Helpers::StubEnv
describe 'initialization' do
it 'defaults to :gitlab address' do
diff --git a/qa/spec/runtime/env_spec.rb b/qa/spec/runtime/env_spec.rb
index 1d702b70d10..fb18311bb52 100644
--- a/qa/spec/runtime/env_spec.rb
+++ b/qa/spec/runtime/env_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe QA::Runtime::Env do
- include Helpers::StubENV
+ include QA::Support::Helpers::StubEnv
shared_examples 'boolean method' do |**kwargs|
it_behaves_like 'boolean method with parameter', kwargs
diff --git a/qa/spec/runtime/namespace_spec.rb b/qa/spec/runtime/namespace_spec.rb
index 92836862864..04d4769b07b 100644
--- a/qa/spec/runtime/namespace_spec.rb
+++ b/qa/spec/runtime/namespace_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe QA::Runtime::Namespace do
- include Helpers::StubENV
+ include QA::Support::Helpers::StubEnv
describe '.name' do
context 'when CACHE_NAMESPACE_NAME is not defined' do
diff --git a/qa/spec/runtime/release_spec.rb b/qa/spec/runtime/release_spec.rb
index b4e278fb546..29871cbe301 100644
--- a/qa/spec/runtime/release_spec.rb
+++ b/qa/spec/runtime/release_spec.rb
@@ -30,23 +30,4 @@ RSpec.describe QA::Runtime::Release do
end
end
end
-
- context 'when release version does not have extension strategy' do
- before do
- allow_any_instance_of(described_class)
- .to receive(:version).and_return('something')
- end
-
- describe '#strategy' do
- it 'raises error' do
- expect { subject.strategy }.to raise_error(LoadError)
- end
- end
-
- describe 'delegated class methods' do
- it 'raises error' do
- expect { described_class.some_method(2, 3) }.to raise_error(LoadError)
- end
- end
- end
end
diff --git a/qa/spec/spec_helper.rb b/qa/spec/spec_helper.rb
index 0df7b94b894..4f0f93bf020 100644
--- a/qa/spec/spec_helper.rb
+++ b/qa/spec/spec_helper.rb
@@ -1,33 +1,30 @@
# frozen_string_literal: true
require_relative '../qa'
-require 'rspec/retry'
-require 'rspec-parameterized'
+
+require 'securerandom'
+require 'pathname'
require 'active_support/core_ext/hash'
require 'active_support/core_ext/object/blank'
require_relative 'qa_deprecation_toolkit_env'
QaDeprecationToolkitEnv.configure!
-if ENV['CI'] && QA::Runtime::Env.knapsack? && !ENV['NO_KNAPSACK']
- require 'knapsack'
- Knapsack::Adapters::RSpecAdapter.bind
-end
+Knapsack::Adapters::RSpecAdapter.bind if ENV['CI'] && QA::Runtime::Env.knapsack? && !ENV['NO_KNAPSACK']
QA::Runtime::Browser.configure!
QA::Runtime::AllureReport.configure!
QA::Runtime::Scenario.from_env(QA::Runtime::Env.runtime_scenario_attributes)
-Dir[::File.join(__dir__, "support/helpers/*.rb")].sort.each { |f| require f }
-Dir[::File.join(__dir__, "support/matchers/*.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 }
RSpec.configure do |config|
- config.include ::Matchers
+ config.include QA::Support::Matchers::EventuallyMatcher
+ config.include QA::Support::Matchers::HaveMatcher
- config.add_formatter QA::Specs::Helpers::ContextFormatter
- config.add_formatter QA::Specs::Helpers::QuarantineFormatter
+ config.add_formatter QA::Support::Formatters::ContextFormatter
+ config.add_formatter QA::Support::Formatters::QuarantineFormatter
+ config.add_formatter QA::Support::Formatters::TestStatsFormatter if QA::Runtime::Env.export_metrics?
config.before do |example|
QA::Runtime::Logger.debug("\nStarting test: #{example.full_description}\n")
diff --git a/qa/spec/specs/allure_report_spec.rb b/qa/spec/specs/allure_report_spec.rb
index 27bc0dd3d1d..34116ca6cbd 100644
--- a/qa/spec/specs/allure_report_spec.rb
+++ b/qa/spec/specs/allure_report_spec.rb
@@ -1,9 +1,7 @@
# frozen_string_literal: true
-require 'allure-rspec'
-
describe QA::Runtime::AllureReport do
- include Helpers::StubENV
+ include QA::Support::Helpers::StubEnv
let(:rspec_config) { double('RSpec::Core::Configuration', 'add_formatter': nil, after: nil) }
@@ -70,7 +68,8 @@ describe QA::Runtime::AllureReport do
it 'adds rspec and metadata formatter' do
expect(rspec_config).to have_received(:add_formatter).with(AllureRspecFormatter).ordered
- expect(rspec_config).to have_received(:add_formatter).with(QA::Support::AllureMetadataFormatter).ordered
+ expect(rspec_config).to have_received(:add_formatter)
+ .with(QA::Support::Formatters::AllureMetadataFormatter).ordered
end
it 'configures screenshot saving' do
diff --git a/qa/spec/specs/helpers/context_selector_spec.rb b/qa/spec/specs/helpers/context_selector_spec.rb
index cbdbe6698ae..0152fee6f5b 100644
--- a/qa/spec/specs/helpers/context_selector_spec.rb
+++ b/qa/spec/specs/helpers/context_selector_spec.rb
@@ -3,14 +3,14 @@
require 'rspec/core/sandbox'
RSpec.describe QA::Specs::Helpers::ContextSelector do
- include Helpers::StubENV
+ include QA::Support::Helpers::StubEnv
include QA::Specs::Helpers::RSpec
around do |ex|
QA::Runtime::Scenario.define(:gitlab_address, 'https://staging.gitlab.com')
RSpec::Core::Sandbox.sandboxed do |config|
- config.formatter = QA::Specs::Helpers::ContextFormatter
+ config.formatter = QA::Support::Formatters::ContextFormatter
# If there is an example-within-an-example, we want to make sure the inner example
# does not get a reference to the outer example (the real spec) if it calls
diff --git a/qa/spec/specs/helpers/quarantine_spec.rb b/qa/spec/specs/helpers/quarantine_spec.rb
index 548a8510988..8ea375cdb05 100644
--- a/qa/spec/specs/helpers/quarantine_spec.rb
+++ b/qa/spec/specs/helpers/quarantine_spec.rb
@@ -3,12 +3,12 @@
require 'rspec/core/sandbox'
RSpec.describe QA::Specs::Helpers::Quarantine do
- include Helpers::StubENV
+ include QA::Support::Helpers::StubEnv
include QA::Specs::Helpers::RSpec
around do |ex|
RSpec::Core::Sandbox.sandboxed do |config|
- config.formatter = QA::Specs::Helpers::QuarantineFormatter
+ config.formatter = QA::Support::Formatters::QuarantineFormatter
# If there is an example-within-an-example, we want to make sure the inner example
# does not get a reference to the outer example (the real spec) if it calls
diff --git a/qa/spec/specs/parallel_runner_spec.rb b/qa/spec/specs/parallel_runner_spec.rb
index c2d28bf81fb..d77b50fbe09 100644
--- a/qa/spec/specs/parallel_runner_spec.rb
+++ b/qa/spec/specs/parallel_runner_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe QA::Specs::ParallelRunner do
- include Helpers::StubENV
+ include QA::Support::Helpers::StubEnv
before do
allow(QA::Runtime::Scenario).to receive(:attributes).and_return(parallel: true)
diff --git a/qa/spec/support/allure_metadata_formatter_spec.rb b/qa/spec/support/formatters/allure_metadata_formatter_spec.rb
index cb208642716..631d2eda54f 100644
--- a/qa/spec/support/allure_metadata_formatter_spec.rb
+++ b/qa/spec/support/formatters/allure_metadata_formatter_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
-describe QA::Support::AllureMetadataFormatter do
- include Helpers::StubENV
+describe QA::Support::Formatters::AllureMetadataFormatter do
+ include QA::Support::Helpers::StubEnv
let(:formatter) { described_class.new(StringIO.new) }
@@ -34,7 +34,6 @@ describe QA::Support::AllureMetadataFormatter do
formatter.example_started(rspec_example_notification)
aggregate_failures do
- expect(rspec_example).to have_received(:tms).with('Testcase', 'testcase')
expect(rspec_example).to have_received(:issue).with('Quarantine issue', 'issue')
expect(rspec_example).to have_received(:add_link).with(name: "Job(#{ci_job})", url: ci_job_url)
expect(rspec_example).to have_received(:issue).with(
diff --git a/qa/spec/support/formatters/test_stats_formatter_spec.rb b/qa/spec/support/formatters/test_stats_formatter_spec.rb
new file mode 100644
index 00000000000..fec7ec1c7c0
--- /dev/null
+++ b/qa/spec/support/formatters/test_stats_formatter_spec.rb
@@ -0,0 +1,171 @@
+# frozen_string_literal: true
+
+require 'rspec/core/sandbox'
+
+describe QA::Support::Formatters::TestStatsFormatter do
+ include QA::Support::Helpers::StubEnv
+ include QA::Specs::Helpers::RSpec
+
+ let(:url) { "http://influxdb.net" }
+ let(:token) { "token" }
+ let(:ci_timestamp) { "2021-02-23T20:58:41Z" }
+ let(:ci_job_name) { "test-job 1/5" }
+ let(:ci_job_url) { "url" }
+ let(:ci_pipeline_url) { "url" }
+ let(:ci_pipeline_id) { "123" }
+ let(:run_type) { 'staging-full' }
+ let(:reliable) { 'false' }
+ let(:quarantined) { 'false' }
+ let(:influx_client) { instance_double('InfluxDB2::Client', create_write_api: influx_write_api) }
+ let(:influx_write_api) { instance_double('InfluxDB2::WriteApi', write: nil) }
+
+ let(:influx_client_args) do
+ {
+ bucket: 'e2e-test-stats',
+ org: 'gitlab-qa',
+ use_ssl: false,
+ precision: InfluxDB2::WritePrecision::NANOSECOND
+ }
+ end
+
+ let(:data) do
+ {
+ name: 'test-stats',
+ time: DateTime.strptime(ci_timestamp).to_time,
+ tags: {
+ name: 'stats export spec',
+ file_path: './spec/support/formatters/test_stats_formatter_spec.rb',
+ status: :passed,
+ reliable: reliable,
+ quarantined: quarantined,
+ retried: "false",
+ job_name: "test-job",
+ merge_request: "false",
+ run_type: run_type
+ },
+ fields: {
+ id: './spec/support/formatters/test_stats_formatter_spec.rb[1:1]',
+ run_time: 0,
+ retry_attempts: 0,
+ job_url: ci_job_url,
+ pipeline_url: ci_pipeline_url,
+ pipeline_id: ci_pipeline_id
+ }
+ }
+ end
+
+ def run_spec(&spec)
+ spec ||= -> { it('spec') {} }
+
+ describe_successfully('stats export', &spec)
+ send_stop_notification
+ end
+
+ around do |example|
+ RSpec::Core::Sandbox.sandboxed do |config|
+ config.formatter = QA::Support::Formatters::TestStatsFormatter
+
+ config.before(:context) { RSpec.current_example = nil }
+
+ example.run
+ end
+ end
+
+ before do
+ allow(InfluxDB2::Client).to receive(:new).with(url, token, **influx_client_args) { influx_client }
+ end
+
+ context "without influxdb variables configured" do
+ it "skips export without influxdb url" do
+ stub_env('QA_INFLUXDB_URL', nil)
+ stub_env('QA_INFLUXDB_TOKEN', nil)
+
+ run_spec
+
+ expect(influx_client).not_to have_received(:create_write_api)
+ end
+
+ it "skips export without influxdb token" do
+ stub_env('QA_INFLUXDB_URL', url)
+ stub_env('QA_INFLUXDB_TOKEN', nil)
+
+ run_spec
+
+ expect(influx_client).not_to have_received(:create_write_api)
+ end
+ end
+
+ context 'with influxdb variables configured' do
+ let(:spec_name) { 'exports data' }
+ let(:run_type) { ci_job_name.gsub(%r{ \d{1,2}/\d{1,2}}, '') }
+
+ before do
+ stub_env('QA_INFLUXDB_URL', url)
+ stub_env('QA_INFLUXDB_TOKEN', token)
+ stub_env('CI_PIPELINE_CREATED_AT', ci_timestamp)
+ stub_env('CI_JOB_URL', ci_job_url)
+ stub_env('CI_JOB_NAME', ci_job_name)
+ stub_env('CI_PIPELINE_URL', ci_pipeline_url)
+ stub_env('CI_PIPELINE_ID', ci_pipeline_id)
+ stub_env('CI_MERGE_REQUEST_IID', nil)
+ stub_env('TOP_UPSTREAM_MERGE_REQUEST_IID', nil)
+ stub_env('QA_RUN_TYPE', run_type)
+ end
+
+ context 'with reliable spec' do
+ let(:reliable) { 'true' }
+
+ it 'exports data to influxdb with correct reliable tag' do
+ run_spec do
+ it('spec', :reliable) {}
+ end
+
+ expect(influx_write_api).to have_received(:write).with(data: [data])
+ end
+ end
+
+ context 'with quarantined spec' do
+ let(:quarantined) { 'true' }
+
+ it 'exports data to influxdb with correct quarantine tag' do
+ run_spec do
+ it('spec', :quarantine) {}
+ end
+
+ expect(influx_write_api).to have_received(:write).with(data: [data])
+ end
+ end
+
+ context 'with staging full run' do
+ let(:run_type) { 'staging-full' }
+
+ before do
+ stub_env('CI_PROJECT_NAME', 'staging')
+ stub_env('QA_RUN_TYPE', nil)
+ end
+
+ it 'exports data to influxdb with correct run type' do
+ run_spec
+
+ expect(influx_write_api).to have_received(:write).with(data: [data])
+ end
+ end
+
+ context 'with staging sanity no admin' do
+ let(:run_type) { 'staging-sanity-no-admin' }
+
+ before do
+ stub_env('CI_PROJECT_NAME', 'staging')
+ stub_env('NO_ADMIN', 'true')
+ stub_env('SMOKE_ONLY', 'true')
+ stub_env('QA_RUN_TYPE', nil)
+ end
+
+ it 'exports data to influxdb with correct run type' do
+ run_spec
+
+ expect(influx_write_api).to have_received(:write).with(data: [data])
+ end
+ end
+ end
+end
diff --git a/qa/spec/support/helpers/stub_env.rb b/qa/spec/support/helpers/stub_env.rb
deleted file mode 100644
index de8d2f47adf..00000000000
--- a/qa/spec/support/helpers/stub_env.rb
+++ /dev/null
@@ -1,42 +0,0 @@
-# frozen_string_literal: true
-
-# Inspired by https://github.com/ljkbennett/stub_env/blob/master/lib/stub_env/helpers.rb
-module Helpers
- module StubENV
- def stub_env(key_or_hash, value = nil)
- init_stub unless env_stubbed?
-
- if key_or_hash.is_a? Hash
- key_or_hash.each { |k, v| add_stubbed_value(k, v) }
- else
- add_stubbed_value key_or_hash, value
- end
- end
-
- private
-
- STUBBED_KEY = '__STUBBED__'
-
- def add_stubbed_value(key, value)
- allow(ENV).to receive(:[]).with(key).and_return(value)
- allow(ENV).to receive(:key?).with(key).and_return(true)
- allow(ENV).to receive(:fetch).with(key).and_return(value)
- allow(ENV).to receive(:fetch).with(key, anything) do |_, default_val|
- value || default_val
- end
- end
-
- def env_stubbed?
- ENV[STUBBED_KEY]
- end
-
- def init_stub
- allow(ENV).to receive(:[]).and_call_original
- allow(ENV).to receive(:key?).and_call_original
- allow(ENV).to receive(:fetch).and_call_original
- # Prevent secrets from leaking in CI
- allow(ENV).to receive(:inspect).and_return([])
- add_stubbed_value(STUBBED_KEY, true)
- end
- end
-end
diff --git a/qa/spec/support/matchers/eventually_matcher.rb b/qa/spec/support/matchers/eventually_matcher.rb
deleted file mode 100644
index 7a35a3165ae..00000000000
--- a/qa/spec/support/matchers/eventually_matcher.rb
+++ /dev/null
@@ -1,133 +0,0 @@
-# frozen_string_literal: true
-
-# Rspec matcher with build in retry logic
-#
-# USAGE:
-#
-# Basic
-# expect { Something.that.takes.time.to_appear }.to eventually_eq(expected_result)
-# expect { Something.that.takes.time.to_appear }.not_to eventually_eq(expected_result)
-#
-# With duration and attempts override
-# expect { Something.that.takes.time.to_appear }.to eventually_eq(expected_result).within(max_duration: 10, max_attempts: 5)
-
-module Matchers
- %w[
- eq
- be
- include
- be_truthy
- be_falsey
- be_empty
- ].each do |op|
- RSpec::Matchers.define(:"eventually_#{op}") do |*expected|
- chain(:within) do |kwargs = {}|
- @retry_args = kwargs
- @retry_args[:sleep_interval] = 0.5 unless @retry_args[:sleep_interval]
- end
-
- def supports_block_expectations?
- true
- end
-
- match { |actual| wait_and_check(actual, :default_expectation) }
-
- match_when_negated { |actual| wait_and_check(actual, :when_negated_expectation) }
-
- description do
- "eventually #{operator_msg} #{expected.inspect}"
- end
-
- failure_message do
- "#{e}:\nexpected to #{description}, last attempt was #{@result.nil? ? 'nil' : @result}"
- end
-
- failure_message_when_negated do
- "#{e}:\nexpected not to #{description}, last attempt was #{@result.nil? ? 'nil' : @result}"
- end
-
- # Execute rspec expectation within retrier
- #
- # @param [Proc] actual
- # @param [Symbol] expectation_name
- # @return [Boolean]
- def wait_and_check(actual, expectation_name)
- attempt = 0
-
- QA::Runtime::Logger.debug("Running eventually matcher with '#{operator_msg}' operator")
- QA::Support::Retrier.retry_until(**@retry_args) do
- QA::Runtime::Logger.debug("evaluating expectation, attempt: #{attempt += 1}")
-
- public_send(expectation_name, actual)
- rescue RSpec::Expectations::ExpectationNotMetError, QA::Resource::ApiFabricator::ResourceNotFoundError
- false
- end
- rescue QA::Support::Repeater::RetriesExceededError, QA::Support::Repeater::WaitExceededError => e
- @e = e
- false
- end
-
- # Execute rspec expectation
- #
- # @param [Proc] actual
- # @return [void]
- def default_expectation(actual)
- expect(result(&actual)).to public_send(*expectation_args)
- end
-
- # Execute negated rspec expectation
- #
- # @param [Proc] actual
- # @return [void]
- def when_negated_expectation(actual)
- expect(result(&actual)).not_to public_send(*expectation_args)
- end
-
- # Result of actual block
- #
- # @return [Object]
- def result
- @result = yield
- end
-
- # Error message placeholder to indicate waiter did not fail properly
- # This message should not appear under normal circumstances since it should
- # always be assigned from repeater
- #
- # @return [String]
- def e
- @e ||= 'Waiter did not fail!'
- end
-
- # Operator message
- #
- # @return [String]
- def operator_msg
- case operator
- when 'eq' then 'equal'
- else operator
- end
- end
-
- # Expect operator
- #
- # @return [String]
- def operator
- @operator ||= name.to_s.match(/eventually_(.+?)$/).to_a[1].to_s
- end
-
- # Expectation args
- #
- # @return [String, Array]
- def expectation_args
- if operator.include?('truthy') || operator.include?('falsey') || operator.include?('empty')
- operator
- elsif operator == "include" && expected.is_a?(Array)
- [operator, *expected]
- else
- [operator, expected]
- end
- end
- end
- end
-end
diff --git a/qa/spec/support/matchers/have_matcher.rb b/qa/spec/support/matchers/have_matcher.rb
deleted file mode 100644
index 81288b97e6f..00000000000
--- a/qa/spec/support/matchers/have_matcher.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-# frozen_string_literal: true
-
-module Matchers
- PREDICATE_TARGETS = %w[
- element
- file_content
- assignee
- child_pipeline
- content
- design
- file
- issue
- job
- package
- pipeline
- related_issue_item
- snippet_description
- tag
- ].each do |predicate|
- RSpec::Matchers.define "have_#{predicate}" do |*args, **kwargs|
- match do |page_object|
- page_object.public_send("has_#{predicate}?", *args, **kwargs) # rubocop:disable GitlabSecurity/PublicSend
- end
-
- match_when_negated do |page_object|
- page_object.public_send("has_no_#{predicate}?", *args, **kwargs) # rubocop:disable GitlabSecurity/PublicSend
- end
- end
- end
-end
diff --git a/qa/spec/support/matchers/have_text.rb b/qa/spec/support/matchers/have_text.rb
deleted file mode 100644
index 4e6fbf1f6d6..00000000000
--- a/qa/spec/support/matchers/have_text.rb
+++ /dev/null
@@ -1,48 +0,0 @@
-# frozen_string_literal: true
-
-module Matchers
- class HaveText
- def initialize(expected_text, **kwargs)
- @expected_text = expected_text
- @kwargs = kwargs
- end
-
- def matches?(actual)
- @actual = wrap(actual)
- @actual.has_text?(@expected_text, **@kwargs)
- end
-
- def does_not_match?(actual)
- @actual = wrap(actual)
- @actual.has_no_text?(@expected_text, **@kwargs)
- end
-
- def failure_message
- "expected to find text \"#{@expected_text}\" in \"#{normalized_actual_text}\""
- end
-
- def failure_message_when_negated
- "expected not to find text \"#{@expected_text}\" in \"#{normalized_actual_text}\""
- end
-
- def normalized_actual_text
- @actual.text.gsub(/\s+/, " ")
- end
-
- # From https://github.com/teamcapybara/capybara/blob/fe5940c6afbfe32152df936ce03ad1371ae05354/lib/capybara/rspec/matchers/base.rb#L66
- def wrap(actual)
- actual = actual.to_capybara_node if actual.respond_to?(:to_capybara_node)
- @context_el = if actual.respond_to?(:has_selector?)
- actual
- else
- Capybara.string(actual.to_s)
- end
- end
- end
-
- def have_text(text, **kwargs) # rubocop:disable Naming/PredicateName
- HaveText.new(text, **kwargs)
- end
-
- alias_method :have_content, :have_text
-end
diff --git a/qa/spec/support/repeater_spec.rb b/qa/spec/support/repeater_spec.rb
index 18ccbf250cb..da8d6b18fb0 100644
--- a/qa/spec/support/repeater_spec.rb
+++ b/qa/spec/support/repeater_spec.rb
@@ -1,7 +1,5 @@
# frozen_string_literal: true
-require 'logger'
-require 'timecop'
require 'active_support/core_ext/integer/time'
RSpec.describe QA::Support::Repeater do
diff --git a/qa/spec/support/retrier_spec.rb b/qa/spec/support/retrier_spec.rb
index 4e27915553c..9ad3e85fea9 100644
--- a/qa/spec/support/retrier_spec.rb
+++ b/qa/spec/support/retrier_spec.rb
@@ -1,8 +1,5 @@
# frozen_string_literal: true
-require 'logger'
-require 'timecop'
-
RSpec.describe QA::Support::Retrier do
before do
logger = ::Logger.new $stdout
diff --git a/qa/spec/support/waiter_spec.rb b/qa/spec/support/waiter_spec.rb
index 5b0c2c95d0d..d0b216b5dc1 100644
--- a/qa/spec/support/waiter_spec.rb
+++ b/qa/spec/support/waiter_spec.rb
@@ -1,7 +1,5 @@
# frozen_string_literal: true
-require 'logger'
-
RSpec.describe QA::Support::Waiter do
before do
logger = ::Logger.new $stdout