2019-04-11 08:02:24 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-03-09 06:18:55 -05:00
|
|
|
describe QA::Runtime::Release do
|
|
|
|
context 'when release version has extension strategy' do
|
2017-03-13 08:54:33 -04:00
|
|
|
let(:strategy) { spy('strategy') }
|
2017-03-09 06:18:55 -05:00
|
|
|
|
|
|
|
before do
|
2017-03-13 08:54:33 -04:00
|
|
|
stub_const('QA::CE::Strategy', strategy)
|
|
|
|
stub_const('QA::EE::Strategy', strategy)
|
2017-03-09 06:18:55 -05:00
|
|
|
end
|
|
|
|
|
2017-03-13 08:54:33 -04:00
|
|
|
describe '#version' do
|
|
|
|
it 'return either CE or EE version' do
|
|
|
|
expect(subject.version).to eq(:CE).or eq(:EE)
|
2017-03-09 06:18:55 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#strategy' do
|
|
|
|
it 'return the strategy constant' do
|
2017-03-13 08:54:33 -04:00
|
|
|
expect(subject.strategy).to eq strategy
|
2017-03-09 06:18:55 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'delegated class methods' do
|
|
|
|
it 'delegates all calls to strategy class' do
|
|
|
|
described_class.some_method(1, 2)
|
|
|
|
|
|
|
|
expect(strategy).to have_received(:some_method)
|
|
|
|
.with(1, 2)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when release version does not have extension strategy' do
|
2017-03-13 08:54:33 -04:00
|
|
|
before do
|
|
|
|
allow_any_instance_of(described_class)
|
|
|
|
.to receive(:version).and_return('something')
|
2017-03-09 06:18:55 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
describe '#strategy' do
|
|
|
|
it 'raises error' do
|
2017-03-13 08:54:33 -04:00
|
|
|
expect { subject.strategy }.to raise_error(LoadError)
|
2017-03-09 06:18:55 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-03-13 08:54:33 -04:00
|
|
|
describe 'delegated class methods' do
|
|
|
|
it 'raises error' do
|
|
|
|
expect { described_class.some_method(2, 3) }.to raise_error(LoadError)
|
2017-03-09 06:18:55 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|