diff options
Diffstat (limited to 'spec/lib/gitlab/ci/config/external/rules_spec.rb')
-rw-r--r-- | spec/lib/gitlab/ci/config/external/rules_spec.rb | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/spec/lib/gitlab/ci/config/external/rules_spec.rb b/spec/lib/gitlab/ci/config/external/rules_spec.rb index 89ea13d710d..9a5c29befa2 100644 --- a/spec/lib/gitlab/ci/config/external/rules_spec.rb +++ b/spec/lib/gitlab/ci/config/external/rules_spec.rb @@ -16,7 +16,7 @@ RSpec.describe Gitlab::Ci::Config::External::Rules do it { is_expected.to eq(true) } end - context 'when there is a rule' do + context 'when there is a rule with if' do let(:rule_hashes) { [{ if: '$MY_VAR == "hello"' }] } context 'when the rule matches' do @@ -31,5 +31,23 @@ RSpec.describe Gitlab::Ci::Config::External::Rules do it { is_expected.to eq(false) } end end + + context 'when there is a rule with if and when' do + let(:rule_hashes) { [{ if: '$MY_VAR == "hello"', when: 'on_success' }] } + + it 'raises an error' do + expect { result }.to raise_error(described_class::InvalidIncludeRulesError, + 'invalid include rule: {:if=>"$MY_VAR == \"hello\"", :when=>"on_success"}') + end + end + + context 'when there is a rule with exists' do + let(:rule_hashes) { [{ exists: ['$MY_VAR'] }] } + + it 'raises an error' do + expect { result }.to raise_error(described_class::InvalidIncludeRulesError, + 'invalid include rule: {:exists=>["$MY_VAR"]}') + end + end end end |