summaryrefslogtreecommitdiff
path: root/qa/spec/support/formatters/allure_metadata_formatter_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'qa/spec/support/formatters/allure_metadata_formatter_spec.rb')
-rw-r--r--qa/spec/support/formatters/allure_metadata_formatter_spec.rb45
1 files changed, 45 insertions, 0 deletions
diff --git a/qa/spec/support/formatters/allure_metadata_formatter_spec.rb b/qa/spec/support/formatters/allure_metadata_formatter_spec.rb
new file mode 100644
index 00000000000..631d2eda54f
--- /dev/null
+++ b/qa/spec/support/formatters/allure_metadata_formatter_spec.rb
@@ -0,0 +1,45 @@
+# frozen_string_literal: true
+
+describe QA::Support::Formatters::AllureMetadataFormatter do
+ include QA::Support::Helpers::StubEnv
+
+ let(:formatter) { described_class.new(StringIO.new) }
+
+ let(:rspec_example_notification) { double('RSpec::Core::Notifications::ExampleNotification', example: rspec_example) }
+ let(:rspec_example) do
+ double(
+ 'RSpec::Core::Example',
+ tms: nil,
+ issue: nil,
+ add_link: nil,
+ attempts: 0,
+ file_path: 'file/path/spec.rb',
+ metadata: {
+ testcase: 'testcase',
+ quarantine: { issue: 'issue' }
+ }
+ )
+ end
+
+ let(:ci_job) { 'ee:relative 5' }
+ let(:ci_job_url) { 'url' }
+
+ before do
+ stub_env('CI', 'true')
+ stub_env('CI_JOB_NAME', ci_job)
+ stub_env('CI_JOB_URL', ci_job_url)
+ end
+
+ it "adds additional data to report" do
+ formatter.example_started(rspec_example_notification)
+
+ aggregate_failures do
+ 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(
+ 'Failure issues',
+ 'https://gitlab.com/gitlab-org/gitlab/-/issues?scope=all&state=opened&search=spec.rb'
+ )
+ end
+ end
+end