|
6 | 6 | include XmlDocs |
7 | 7 | include JsonDocs |
8 | 8 | include GeoCombine::Exceptions |
| 9 | + |
9 | 10 | let(:full_geobl) { described_class.new(full_geoblacklight) } |
10 | 11 | let(:enhanced_geobl) { described_class.new(basic_geoblacklight, 'layer_geom_type_s' => 'esriGeometryPolygon') } |
11 | 12 | let(:basic_geobl) { described_class.new(basic_geoblacklight) } |
|
62 | 63 | end |
63 | 64 | end |
64 | 65 |
|
65 | | - describe '#valid?' do |
| 66 | + describe '#validate!' do |
66 | 67 | it 'a valid geoblacklight-schema document should be valid' do |
67 | | - expect(full_geobl.valid?).to be true |
| 68 | + expect(full_geobl).to be_valid |
68 | 69 | end |
69 | 70 |
|
70 | 71 | context 'must have required fields' do |
|
78 | 79 | ].each do |field| |
79 | 80 | it field do |
80 | 81 | full_geobl.metadata.delete field |
81 | | - expect { full_geobl.valid? }.to raise_error(JSON::Schema::ValidationError, /#{field}/) |
| 82 | + expect { full_geobl.validate! }.to raise_error(JSON::Schema::ValidationError, /#{field}/) |
82 | 83 | end |
83 | 84 | end |
84 | 85 | end |
|
104 | 105 | ].each do |field| |
105 | 106 | it field do |
106 | 107 | full_geobl.metadata.delete field |
107 | | - expect { full_geobl.valid? }.not_to raise_error |
| 108 | + expect { full_geobl.validate! }.not_to raise_error |
108 | 109 | end |
109 | 110 | end |
110 | 111 | end |
|
119 | 120 | ].each do |field| |
120 | 121 | it field do |
121 | 122 | full_geobl.metadata.delete field |
122 | | - expect { full_geobl.valid? }.not_to raise_error |
| 123 | + expect { full_geobl.validate! }.not_to raise_error |
123 | 124 | end |
124 | 125 | end |
125 | 126 | end |
126 | 127 |
|
127 | 128 | it 'an invalid document' do |
128 | | - expect { basic_geobl.valid? }.to raise_error JSON::Schema::ValidationError |
| 129 | + expect { basic_geobl.validate! }.to raise_error JSON::Schema::ValidationError |
129 | 130 | end |
130 | 131 |
|
131 | 132 | it 'calls the dct_references_s validator' do |
132 | | - expect(enhanced_geobl).to receive(:dct_references_validate!) |
| 133 | + expect(enhanced_geobl).to receive(:validate_references!) |
133 | 134 | enhanced_geobl.valid? |
134 | 135 | end |
135 | | - |
136 | | - it 'validates spatial bounding box' do |
137 | | - expect(JSON::Validator).to receive(:validate!).and_return true |
138 | | - expect { basic_geobl.valid? } |
139 | | - .to raise_error GeoCombine::Exceptions::InvalidGeometry |
140 | | - end |
141 | 136 | end |
142 | 137 |
|
143 | | - describe '#dct_references_validate!' do |
| 138 | + describe '#validate_references!' do |
144 | 139 | context 'with valid document' do |
145 | 140 | it 'is valid' do |
146 | | - expect(full_geobl.dct_references_validate!).to be true |
| 141 | + expect { full_geobl.validate_references! }.not_to raise_error |
147 | 142 | end |
148 | 143 | end |
149 | 144 |
|
|
173 | 168 | end |
174 | 169 |
|
175 | 170 | it 'unparseable json' do |
176 | | - expect { bad_ref.dct_references_validate! }.to raise_error JSON::ParserError |
| 171 | + expect { bad_ref.validate_references! }.to raise_error JSON::ParserError |
177 | 172 | end |
178 | 173 |
|
179 | 174 | it 'not a hash' do |
180 | | - expect { not_hash.dct_references_validate! }.to raise_error GeoCombine::Exceptions::InvalidDCTReferences |
| 175 | + expect { not_hash.validate_references! }.to raise_error GeoCombine::Exceptions::InvalidDCTReferences |
181 | 176 | end |
182 | 177 | end |
183 | 178 | end |
184 | 179 |
|
185 | | - describe 'spatial_validate!' do |
| 180 | + describe 'validate_spatial!' do |
186 | 181 | context 'when valid' do |
187 | | - it { expect { full_geobl.spatial_validate! }.not_to raise_error } |
| 182 | + it { expect { full_geobl.validate_spatial! }.not_to raise_error } |
188 | 183 | end |
189 | 184 |
|
190 | 185 | context 'when invalid' do |
191 | | - it { expect { basic_geobl.spatial_validate! }.to raise_error GeoCombine::Exceptions::InvalidGeometry } |
| 186 | + it { expect { basic_geobl.validate_spatial! }.to raise_error GeoCombine::Exceptions::InvalidGeometry } |
192 | 187 | end |
193 | 188 | end |
194 | 189 |
|
|
0 commit comments