summaryrefslogtreecommitdiff
path: root/qa
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-03-13 13:54:33 +0100
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-03-13 13:54:33 +0100
commit0731365b9de9411a937bd786d6e3fd7e10099800 (patch)
treeec4d8356380c2fc898847f0125a12c965e52f7dc /qa
parentcbba91840d7c640f94e604575ce018a44f9937d1 (diff)
downloadgitlab-ce-0731365b9de9411a937bd786d6e3fd7e10099800.tar.gz
Add GitLab QA CE strategy and simplify inflectorfeature/gb/gitlab-qa-integration-tests
Diffstat (limited to 'qa')
-rw-r--r--qa/qa.rb4
-rw-r--r--qa/qa/ce/strategy.rb15
-rw-r--r--qa/qa/runtime/release.rb24
-rw-r--r--qa/spec/runtime/release_spec.rb53
4 files changed, 35 insertions, 61 deletions
diff --git a/qa/qa.rb b/qa/qa.rb
index 7fe18676634..58cf615cc9f 100644
--- a/qa/qa.rb
+++ b/qa/qa.rb
@@ -78,6 +78,4 @@ module QA
end
end
-if QA::Runtime::Release.has_autoloads?
- require QA::Runtime::Release.autoloads_file
-end
+QA::Runtime::Release.extend_autoloads!
diff --git a/qa/qa/ce/strategy.rb b/qa/qa/ce/strategy.rb
new file mode 100644
index 00000000000..6d1601dfa48
--- /dev/null
+++ b/qa/qa/ce/strategy.rb
@@ -0,0 +1,15 @@
+module QA
+ module CE
+ module Strategy
+ extend self
+
+ def extend_autoloads!
+ # noop
+ end
+
+ def perform_before_hooks
+ # noop
+ end
+ end
+ end
+end
diff --git a/qa/qa/runtime/release.rb b/qa/qa/runtime/release.rb
index 40d24e8d342..4f83a773645 100644
--- a/qa/qa/runtime/release.rb
+++ b/qa/qa/runtime/release.rb
@@ -8,34 +8,20 @@ module QA
# CE to EE.
#
class Release
- def initialize(variant = nil)
- @version = variant || version
-
- begin
- require "qa/#{@version.downcase}/strategy"
- rescue LoadError
- # noop
- end
+ def initialize
+ require "qa/#{version.downcase}/strategy"
end
def version
- File.directory?("#{__dir__}/../ee") ? :EE : :CE
- end
-
- def has_strategy?
- QA.const_defined?("QA::#{@version}::Strategy")
+ @version ||= File.directory?("#{__dir__}/../ee") ? :EE : :CE
end
def strategy
- QA.const_get("QA::#{@version}::Strategy")
+ QA.const_get("QA::#{version}::Strategy")
end
def self.method_missing(name, *args)
- @release ||= self.new
-
- if @release.has_strategy?
- @release.strategy.public_send(name, *args)
- end
+ self.new.strategy.public_send(name, *args)
end
end
end
diff --git a/qa/spec/runtime/release_spec.rb b/qa/spec/runtime/release_spec.rb
index 5d12315be5b..e6b5a8dc315 100644
--- a/qa/spec/runtime/release_spec.rb
+++ b/qa/spec/runtime/release_spec.rb
@@ -1,33 +1,25 @@
describe QA::Runtime::Release do
context 'when release version has extension strategy' do
- subject { described_class.new('VER') }
- let(:strategy) { spy('VER::Strategy') }
+ let(:strategy) { spy('strategy') }
before do
- stub_const('QA::VER::Strategy', strategy)
+ stub_const('QA::CE::Strategy', strategy)
+ stub_const('QA::EE::Strategy', strategy)
end
- describe '#has_strategy?' do
- it 'return true' do
- expect(subject.has_strategy?).to be true
+ describe '#version' do
+ it 'return either CE or EE version' do
+ expect(subject.version).to eq(:CE).or eq(:EE)
end
end
describe '#strategy' do
it 'return the strategy constant' do
- expect(subject.strategy).to eq QA::VER::Strategy
+ expect(subject.strategy).to eq strategy
end
end
describe 'delegated class methods' do
- before do
- allow_any_instance_of(described_class)
- .to receive(:has_strategy?).and_return(true)
-
- allow_any_instance_of(described_class)
- .to receive(:strategy).and_return(strategy)
- end
-
it 'delegates all calls to strategy class' do
described_class.some_method(1, 2)
@@ -38,37 +30,20 @@ describe QA::Runtime::Release do
end
context 'when release version does not have extension strategy' do
- subject { described_class.new('NOVER') }
-
- describe '#has_strategy?' do
- it 'returns false' do
- expect(subject.has_strategy?).to be false
- end
+ before do
+ allow_any_instance_of(described_class)
+ .to receive(:version).and_return('something')
end
describe '#strategy' do
it 'raises error' do
- expect { subject.strategy }.to raise_error(NameError)
+ expect { subject.strategy }.to raise_error(LoadError)
end
end
- describe 'does not delegate class methods' do
- before do
- allow_any_instance_of(described_class)
- .to receive(:has_strategy?).and_return(false)
- end
-
- it 'behaves like a null object and does nothing' do
- expect { described_class.some_method(2, 3) }.not_to raise_error
- end
-
- it 'returns nil' do
- expect(described_class.something).to be_nil
- end
-
- it 'does not delegate to strategy object' do
- expect_any_instance_of(described_class)
- .not_to receive(:strategy)
+ describe 'delegated class methods' do
+ it 'raises error' do
+ expect { described_class.some_method(2, 3) }.to raise_error(LoadError)
end
end
end