From dd85ea6a9dad26acbf8add2777f53faa1cd1ef1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Fri, 7 Sep 2018 00:52:29 +0200 Subject: [QA] Fix arguments passed to RSpec::Core::Runner MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - When -t or --tag are passed, we shouldn't exclude the :orchestrated tag - When test path is passed, we shouldn't append the default test path Signed-off-by: Rémy Coutable --- qa/spec/specs/runner_spec.rb | 60 ++++++++++++++++++++++++++++++-------------- 1 file changed, 41 insertions(+), 19 deletions(-) (limited to 'qa/spec') diff --git a/qa/spec/specs/runner_spec.rb b/qa/spec/specs/runner_spec.rb index b237b954889..cf22d1c9395 100644 --- a/qa/spec/specs/runner_spec.rb +++ b/qa/spec/specs/runner_spec.rb @@ -7,43 +7,65 @@ describe QA::Specs::Runner do end it 'excludes the orchestrated tag by default' do - expect(RSpec::Core::Runner).to receive(:run) - .with(['--tag', '~orchestrated', File.expand_path('../../qa/specs/features', __dir__)], $stderr, $stdout) - .and_return(0) + expect_rspec_runner_arguments(['--tag', '~orchestrated', *described_class::DEFAULT_TEST_PATH_ARGS]) subject.perform end context 'when tty is set' do - subject do - described_class.new.tap do |runner| - runner.tty = true - end - end + subject { described_class.new.tap { |runner| runner.tty = true } } it 'sets the `--tty` flag' do - expect(RSpec::Core::Runner).to receive(:run) - .with(['--tty', '--tag', '~orchestrated', File.expand_path('../../qa/specs/features', __dir__)], $stderr, $stdout) - .and_return(0) + expect_rspec_runner_arguments(['--tty', '--tag', '~orchestrated', *described_class::DEFAULT_TEST_PATH_ARGS]) subject.perform end end context 'when tags are set' do - subject do - described_class.new.tap do |runner| - runner.tags = %i[orchestrated github] - end - end + subject { described_class.new.tap { |runner| runner.tags = %i[orchestrated github] } } it 'focuses on the given tags' do - expect(RSpec::Core::Runner).to receive(:run) - .with(['--tag', 'orchestrated', '--tag', 'github', File.expand_path('../../qa/specs/features', __dir__)], $stderr, $stdout) - .and_return(0) + expect_rspec_runner_arguments(['--tag', 'orchestrated', '--tag', 'github', *described_class::DEFAULT_TEST_PATH_ARGS]) + + subject.perform + end + end + + context 'when "--tag smoke" is set as options' do + subject { described_class.new.tap { |runner| runner.options = %w[--tag smoke] } } + + it 'focuses on the given tag without excluded the orchestrated tag' do + expect_rspec_runner_arguments(['--tag', 'smoke', *described_class::DEFAULT_TEST_PATH_ARGS]) + + subject.perform + end + end + + context 'when "qa/specs/features/foo" is set as options' do + subject { described_class.new.tap { |runner| runner.options = %w[qa/specs/features/foo] } } + + it 'passes the given tests path and excludes the orchestrated tag' do + expect_rspec_runner_arguments(['--tag', '~orchestrated', 'qa/specs/features/foo']) subject.perform end end + + context 'when "-- qa/specs/features/foo" is set as options' do + subject { described_class.new.tap { |runner| runner.options = %w[-- qa/specs/features/foo] } } + + it 'passes the given tests path and excludes the orchestrated tag' do + expect_rspec_runner_arguments(['--tag', '~orchestrated', '--', 'qa/specs/features/foo']) + + subject.perform + end + end + + def expect_rspec_runner_arguments(arguments) + expect(RSpec::Core::Runner).to receive(:run) + .with(arguments, $stderr, $stdout) + .and_return(0) + end end end -- cgit v1.2.1