diff options
Diffstat (limited to 'qa/spec/scenario/template_spec.rb')
-rw-r--r-- | qa/spec/scenario/template_spec.rb | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/qa/spec/scenario/template_spec.rb b/qa/spec/scenario/template_spec.rb index f97fc22daf9..65793734548 100644 --- a/qa/spec/scenario/template_spec.rb +++ b/qa/spec/scenario/template_spec.rb @@ -17,6 +17,24 @@ describe QA::Scenario::Template do expect(feature).to have_received(:enable).with('a-feature') end + it 'allows a feature to be disabled' do + allow(QA::Runtime::Feature).to receive(:enabled?) + .with('another-feature').and_return(true) + + subject.perform({ disable_feature: 'another-feature' }) + + expect(feature).to have_received(:disable).with('another-feature') + end + + it 'does not disable a feature if already disabled' do + allow(QA::Runtime::Feature).to receive(:enabled?) + .with('another-feature').and_return(false) + + subject.perform({ disable_feature: 'another-feature' }) + + expect(feature).not_to have_received(:disable).with('another-feature') + end + it 'ensures an enabled feature is disabled afterwards' do allow(QA::Specs::Runner).to receive(:perform).and_raise('failed test') @@ -25,4 +43,28 @@ describe QA::Scenario::Template do expect(feature).to have_received(:enable).with('a-feature') expect(feature).to have_received(:disable).with('a-feature') end + + it 'ensures a disabled feature is enabled afterwards' do + allow(QA::Specs::Runner).to receive(:perform).and_raise('failed test') + + allow(QA::Runtime::Feature).to receive(:enabled?) + .with('another-feature').and_return(true) + + expect { subject.perform({ disable_feature: 'another-feature' }) }.to raise_error('failed test') + + expect(feature).to have_received(:disable).with('another-feature') + expect(feature).to have_received(:enable).with('another-feature') + end + + it 'ensures a disabled feature is not enabled afterwards if it was disabled earlier' do + allow(QA::Specs::Runner).to receive(:perform).and_raise('failed test') + + allow(QA::Runtime::Feature).to receive(:enabled?) + .with('another-feature').and_return(false) + + expect { subject.perform({ disable_feature: 'another-feature' }) }.to raise_error('failed test') + + expect(feature).not_to have_received(:disable).with('another-feature') + expect(feature).not_to have_received(:enable).with('another-feature') + end end |