|
|
# frozen_string_literal: true
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
|
require 'active_support/core_ext/hash'
|
|
|
|
|
|
|
describe QA::Specs::Runner do
|
|
describe QA::Specs::Runner do
|
|
|
|
shared_examples 'excludes orchestrated' do
|
|
|
|
it 'excludes the orchestrated tag and includes default args' do
|
|
|
|
expect_rspec_runner_arguments(['--tag', '~orchestrated', *described_class::DEFAULT_TEST_PATH_ARGS])
|
|
|
|
|
|
|
|
subject.perform
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
context '#perform' do
|
|
context '#perform' do
|
|
|
before do
|
|
before do
|
|
|
allow(QA::Runtime::Browser).to receive(:configure!)
|
|
allow(QA::Runtime::Browser).to receive(:configure!)
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
it 'excludes the orchestrated tag by default' do
|
|
it_behaves_like 'excludes orchestrated'
|
|
|
expect_rspec_runner_arguments(['--tag', '~orchestrated', *described_class::DEFAULT_TEST_PATH_ARGS])
|
|
|
|
|
|
|
|
|
|
subject.perform
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'when tty is set' do
|
|
context 'when tty is set' do
|
|
|
subject { described_class.new.tap { |runner| runner.tty = true } }
|
|
subject { described_class.new.tap { |runner| runner.tty = true } }
|
| ... | @@ -67,8 +73,6 @@ describe QA::Specs::Runner do |
... | @@ -67,8 +73,6 @@ describe QA::Specs::Runner do |
|
|
allow(QA::Runtime::Env).to receive(:signup_disabled?).and_return(true)
|
|
allow(QA::Runtime::Env).to receive(:signup_disabled?).and_return(true)
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
subject { described_class.new }
|
|
|
|
|
|
|
|
|
|
it 'includes default args and excludes the skip_signup_disabled tag' do
|
|
it 'includes default args and excludes the skip_signup_disabled tag' do
|
|
|
expect_rspec_runner_arguments(['--tag', '~orchestrated', '--tag', '~skip_signup_disabled', *described_class::DEFAULT_TEST_PATH_ARGS])
|
|
expect_rspec_runner_arguments(['--tag', '~orchestrated', '--tag', '~skip_signup_disabled', *described_class::DEFAULT_TEST_PATH_ARGS])
|
|
|
|
|
|
| ... | @@ -76,20 +80,56 @@ describe QA::Specs::Runner do |
... | @@ -76,20 +80,56 @@ describe QA::Specs::Runner do |
|
|
end
|
|
end
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
context 'when git protocol v2 is not supported' do
|
|
context 'testable features' do
|
|
|
|
shared_examples 'one supported feature' do |feature|
|
|
|
before do
|
|
before do
|
|
|
allow(QA::Runtime::Env).to receive(:can_test?).with(:git_protocol_v2).and_return(false)
|
|
QA::Runtime::Env.supported_features.each do |tag, _|
|
|
|
|
allow(QA::Runtime::Env).to receive(:can_test?).with(tag).and_return(false)
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
subject { described_class.new }
|
|
allow(QA::Runtime::Env).to receive(:can_test?).with(feature).and_return(true) unless feature.nil?
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'includes default args and excludes the requires_git_protocol_v2 tag' do
|
|
it 'includes default args and excludes all unsupported tags' do
|
|
|
expect_rspec_runner_arguments(['--tag', '~orchestrated', '--tag', '~requires_git_protocol_v2', *described_class::DEFAULT_TEST_PATH_ARGS])
|
|
expect_rspec_runner_arguments(['--tag', '~orchestrated', *excluded_feature_tags_except(feature), *described_class::DEFAULT_TEST_PATH_ARGS])
|
|
|
|
|
|
|
|
subject.perform
|
|
subject.perform
|
|
|
end
|
|
end
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
|
context 'when only git protocol 2 is supported' do
|
|
|
|
it_behaves_like 'one supported feature', :git_protocol_v2
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when only admin features are supported' do
|
|
|
|
it_behaves_like 'one supported feature', :admin
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when no features are supported' do
|
|
|
|
it_behaves_like 'one supported feature', nil
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when all features are supported' do
|
|
|
|
before do
|
|
|
|
QA::Runtime::Env.supported_features.each do |tag, _|
|
|
|
|
allow(QA::Runtime::Env).to receive(:can_test?).with(tag).and_return(true)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'excludes orchestrated'
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when features are not specified' do
|
|
|
|
it_behaves_like 'excludes orchestrated'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def excluded_feature_tags_except(tag)
|
|
|
|
QA::Runtime::Env.supported_features.except(tag).map do |tag, _|
|
|
|
|
['--tag', "~requires_#{tag}"]
|
|
|
|
end.flatten
|
|
|
|
end
|
|
|
|
|
|
|
def expect_rspec_runner_arguments(arguments)
|
|
def expect_rspec_runner_arguments(arguments)
|
|
|
expect(RSpec::Core::Runner).to receive(:run)
|
|
expect(RSpec::Core::Runner).to receive(:run)
|
|
|
.with(arguments, $stderr, $stdout)
|
|
.with(arguments, $stderr, $stdout)
|
| ... | |
... | |
| ... | | ... | |