diff options
Diffstat (limited to 'qa/spec/specs/runner_spec.rb')
-rw-r--r-- | qa/spec/specs/runner_spec.rb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/qa/spec/specs/runner_spec.rb b/qa/spec/specs/runner_spec.rb index 5cc9ff403cd..e52ca1fb17c 100644 --- a/qa/spec/specs/runner_spec.rb +++ b/qa/spec/specs/runner_spec.rb @@ -14,6 +14,7 @@ RSpec.describe QA::Specs::Runner do allow(QA::Runtime::Browser).to receive(:configure!) QA::Runtime::Scenario.define(:gitlab_address, "http://gitlab.test") + QA::Runtime::Scenario.define(:klass, "QA::Scenario::Test::Instance::All") end it_behaves_like 'excludes orchestrated, transient, and geo' @@ -43,6 +44,43 @@ RSpec.describe QA::Specs::Runner do subject.perform end + it 'writes to file when examples are more than zero' do + allow(RSpec::Core::Runner).to receive(:run).and_return(0) + + expect(File).to receive(:open).with('no_of_examples/test_instance_all.txt', 'w') { '22' } + + subject.perform + end + + it 'does not write to file when zero examples' do + out.string = '0 examples,' + allow(RSpec::Core::Runner).to receive(:run).and_return(0) + + expect(File).not_to receive(:open) + + subject.perform + end + + it 'raises error when Rspec output does not match regex' do + out.string = '0' + allow(RSpec::Core::Runner).to receive(:run).and_return(0) + + expect { subject.perform } + .to raise_error(QA::Specs::Runner::RegexMismatchError, 'Rspec output did not match regex') + end + + context 'when --tag is specified as an option' do + subject { described_class.new.tap { |runner| runner.options = %w[--tag actioncable] } } + + it 'includes the option value in the file name' do + expect_rspec_runner_arguments(['--dry-run', '--tag', '~geo', '--tag', 'actioncable', *described_class::DEFAULT_TEST_PATH_ARGS], [$stderr, anything]) + + expect(File).to receive(:open).with('no_of_examples/test_instance_all_actioncable.txt', 'w') { '22' } + + subject.perform + end + end + after do QA::Runtime::Scenario.attributes.delete(:count_examples_only) end |