diff options
| author | drew cimino <dcimino@gitlab.com> | 2019-06-25 22:54:07 -0400 |
|---|---|---|
| committer | mfluharty <mfluharty@gitlab.com> | 2019-07-04 13:20:45 -0600 |
| commit | cceeeeb397eac91f66f93c8c5bcca80495a32cde (patch) | |
| tree | 26352d6597796cb646671069cc276e1c21b4f031 | |
| parent | 6f5b824a86ed6502cd9ad7181e861bc9597138a3 (diff) | |
| download | gitlab-ce-cceeeeb397eac91f66f93c8c5bcca80495a32cde.tar.gz | |
New and improved error specs for Extendable::Entry
| -rw-r--r-- | spec/lib/gitlab/ci/config/extendable/entry_spec.rb | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/spec/lib/gitlab/ci/config/extendable/entry_spec.rb b/spec/lib/gitlab/ci/config/extendable/entry_spec.rb index d63612053b6..23d6c724d4d 100644 --- a/spec/lib/gitlab/ci/config/extendable/entry_spec.rb +++ b/spec/lib/gitlab/ci/config/extendable/entry_spec.rb @@ -125,9 +125,13 @@ describe Gitlab::Ci::Config::Extendable::Entry do end it 'raises an error' do - expect { subject.extend! } - .to raise_error(described_class::InvalidExtensionError, - /invalid base hash/) + expect { subject.extend! }.to raise_error do |error| + expect(error).to be_a(Gitlab::Ci::Config::Extendable::ExtensionError) + + expect(JSON.parse(error.message)['key']).to eq('test') + expect(JSON.parse(error.message)['context']).to eq(HashWithIndifferentAccess.new(hash)) + expect(JSON.parse(error.message)['errors'].first['message']).to eq('invalid base hashes in `extends`') + end end end @@ -137,9 +141,13 @@ describe Gitlab::Ci::Config::Extendable::Entry do end it 'raises an error' do - expect { subject.extend! } - .to raise_error(described_class::InvalidExtensionError, - /unknown key/) + expect { subject.extend! }.to raise_error do |error| + expect(error).to be_a(Gitlab::Ci::Config::Extendable::ExtensionError) + + expect(JSON.parse(error.message)['key']).to eq('test') + expect(JSON.parse(error.message)['context']).to eq(HashWithIndifferentAccess.new(hash)) + expect(JSON.parse(error.message)['errors'].first['message']).to eq('unknown keys found in `extends`') + end end end @@ -227,9 +235,13 @@ describe Gitlab::Ci::Config::Extendable::Entry do end it 'raises an error' do - expect { subject.extend! } - .to raise_error(described_class::CircularDependencyError, - /circular dependency detected/) + expect { subject.extend! }.to raise_error do |error| + expect(error).to be_a(Gitlab::Ci::Config::Extendable::ExtensionError) + + expect(JSON.parse(error.message)['key']).to eq('test') + expect(JSON.parse(error.message)['context']).to eq(HashWithIndifferentAccess.new(hash)) + expect(JSON.parse(error.message)['errors'].first['message']).to eq('circular dependency detected in `extends`') + end end end @@ -247,8 +259,13 @@ describe Gitlab::Ci::Config::Extendable::Entry do end it 'raises an error' do - expect { subject.extend! } - .to raise_error(described_class::NestingTooDeepError) + expect { subject.extend! }.to raise_error do |error| + expect(error).to be_a(Gitlab::Ci::Config::Extendable::ExtensionError) + + expect(JSON.parse(error.message)['key']).to eq('second') + expect(JSON.parse(error.message)['context']).to eq(HashWithIndifferentAccess.new(hash)) + expect(JSON.parse(error.message)['errors'].first['message']).to eq('nesting too deep in `extends`') + end end end end |
