diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-21 10:08:36 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-21 10:08:36 +0300 |
commit | 48aff82709769b098321c738f3444b9bdaa694c6 (patch) | |
tree | e00c7c43e2d9b603a5a6af576b1685e400410dee /qa/spec/support/run_spec.rb | |
parent | 879f5329ee916a948223f8f43d77fba4da6cd028 (diff) |
Add latest changes from gitlab-org/gitlab@13-5-stable-eev13.5.0-rc42
Diffstat (limited to 'qa/spec/support/run_spec.rb')
-rw-r--r-- | qa/spec/support/run_spec.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/qa/spec/support/run_spec.rb b/qa/spec/support/run_spec.rb new file mode 100644 index 00000000000..62eed71012e --- /dev/null +++ b/qa/spec/support/run_spec.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +RSpec.describe QA::Support::Run do + let(:class_instance) { (Class.new { include QA::Support::Run }).new } + let(:response) { 'successful response' } + let(:command) { 'some command' } + let(:expected_result) { described_class::Result.new("#{command} 2>&1", 0, response) } + + it 'runs successfully' do + expect(Open3).to receive(:capture2e).and_return([+response, double(exitstatus: 0)]) + + expect(class_instance.run(command)).to eq(expected_result) + end + + it 'retries twice and succeeds the third time' do + allow(Open3).to receive(:capture2e).and_return([+'', double(exitstatus: 1)]).twice + allow(Open3).to receive(:capture2e).and_return([+response, double(exitstatus: 0)]) + + expect(class_instance.run(command)).to eq(expected_result) + end + + it 'raises an exception on 3rd failure' do + allow(Open3).to receive(:capture2e).and_return([+'FAILURE', double(exitstatus: 1)]).thrice + + expect { class_instance.run(command) }.to raise_error(QA::Support::Run::CommandError, /The command .* failed \(1\) with the following output:\nFAILURE/) + end +end |