diff options
Diffstat (limited to 'qa/spec')
-rw-r--r-- | qa/spec/runtime/release_spec.rb | 50 | ||||
-rw-r--r-- | qa/spec/scenario/actable_spec.rb | 47 | ||||
-rw-r--r-- | qa/spec/spec_helper.rb | 19 |
3 files changed, 116 insertions, 0 deletions
diff --git a/qa/spec/runtime/release_spec.rb b/qa/spec/runtime/release_spec.rb new file mode 100644 index 00000000000..e6b5a8dc315 --- /dev/null +++ b/qa/spec/runtime/release_spec.rb @@ -0,0 +1,50 @@ +describe QA::Runtime::Release do + context 'when release version has extension strategy' do + let(:strategy) { spy('strategy') } + + before do + stub_const('QA::CE::Strategy', strategy) + stub_const('QA::EE::Strategy', strategy) + end + + 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 strategy + 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 + 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(LoadError) + end + end + + describe 'delegated class methods' do + it 'raises error' do + expect { described_class.some_method(2, 3) }.to raise_error(LoadError) + end + end + end +end diff --git a/qa/spec/scenario/actable_spec.rb b/qa/spec/scenario/actable_spec.rb new file mode 100644 index 00000000000..422763910e4 --- /dev/null +++ b/qa/spec/scenario/actable_spec.rb @@ -0,0 +1,47 @@ +describe QA::Scenario::Actable do + subject do + Class.new do + include QA::Scenario::Actable + + attr_accessor :something + + def do_something(arg = nil) + "some#{arg}" + end + end + end + + describe '.act' do + it 'provides means to run steps' do + result = subject.act { do_something } + + expect(result).to eq 'some' + end + + it 'supports passing variables' do + result = subject.act('thing') do |variable| + do_something(variable) + end + + expect(result).to eq 'something' + end + + it 'returns value from the last method' do + result = subject.act { 'test' } + + expect(result).to eq 'test' + end + end + + describe '.perform' do + it 'makes it possible to pass binding' do + variable = 'something' + + result = subject.perform do |object| + object.something = variable + end + + expect(result).to eq 'something' + end + end +end diff --git a/qa/spec/spec_helper.rb b/qa/spec/spec_helper.rb new file mode 100644 index 00000000000..c07a3234673 --- /dev/null +++ b/qa/spec/spec_helper.rb @@ -0,0 +1,19 @@ +require_relative '../qa' + +RSpec.configure do |config| + config.expect_with :rspec do |expectations| + expectations.include_chain_clauses_in_custom_matcher_descriptions = true + end + + config.mock_with :rspec do |mocks| + mocks.verify_partial_doubles = true + end + + config.shared_context_metadata_behavior = :apply_to_host_groups + config.disable_monkey_patching! + config.expose_dsl_globally = true + config.warnings = true + config.profile_examples = 10 + config.order = :random + Kernel.srand config.seed +end |