|
1234 | 1234 | end
|
1235 | 1235 | end
|
1236 | 1236 |
|
| 1237 | + context 'ignoring changes in sets' do |
| 1238 | + describe '#ignore' do |
| 1239 | + before(:all) do |
| 1240 | + @c1 = OctocatalogDiff::Catalog.create(json: OctocatalogDiff::Spec.fixture_read('catalogs/ignore-parameter-set-1.json')) |
| 1241 | + @c2 = OctocatalogDiff::Catalog.create(json: OctocatalogDiff::Spec.fixture_read('catalogs/ignore-parameter-set-2.json')) |
| 1242 | + @set1 = [ |
| 1243 | + '!', |
| 1244 | + "Myres\fres1\fparameters\fset1", |
| 1245 | + %w(one two three), |
| 1246 | + %w(three two one) |
| 1247 | + ] |
| 1248 | + @set2 = [ |
| 1249 | + '!', |
| 1250 | + "Myres\fres1\fparameters\fset2", |
| 1251 | + %w(a b), |
| 1252 | + %w(a b c) |
| 1253 | + ] |
| 1254 | + @set3 = [ |
| 1255 | + '!', |
| 1256 | + "Myres\fres1\fparameters\fset3", |
| 1257 | + nil, |
| 1258 | + [1, 2, 3] |
| 1259 | + ] |
| 1260 | + end |
| 1261 | + |
| 1262 | + it 'should not filter out a change when attribute does not match' do |
| 1263 | + opts = {} |
| 1264 | + testobj = OctocatalogDiff::CatalogDiff::Differ.new(opts, @c1, @c2) |
| 1265 | + testobj.ignore(type: 'Myres', title: 'res1', attr: "parameters\fmode") |
| 1266 | + result = testobj.diff |
| 1267 | + expect(OctocatalogDiff::Spec.array_contains_partial_array?(result, @set1)).to eq(true) |
| 1268 | + expect(OctocatalogDiff::Spec.array_contains_partial_array?(result, @set2)).to eq(true) |
| 1269 | + expect(OctocatalogDiff::Spec.array_contains_partial_array?(result, @set3)).to eq(true) |
| 1270 | + end |
| 1271 | + |
| 1272 | + it 'should filter out a change when two arrays have set equality' do |
| 1273 | + opts = {} |
| 1274 | + testobj = OctocatalogDiff::CatalogDiff::Differ.new(opts, @c1, @c2) |
| 1275 | + testobj.ignore(type: 'Myres', title: 'res1', attr: "parameters\fset1=s>=") |
| 1276 | + result = testobj.diff |
| 1277 | + expect(OctocatalogDiff::Spec.array_contains_partial_array?(result, @set1)).to eq(false) |
| 1278 | + expect(OctocatalogDiff::Spec.array_contains_partial_array?(result, @set2)).to eq(true) |
| 1279 | + expect(OctocatalogDiff::Spec.array_contains_partial_array?(result, @set3)).to eq(true) |
| 1280 | + end |
| 1281 | + |
| 1282 | + it 'should not filter out a change when two arrays are not equivalent sets' do |
| 1283 | + opts = {} |
| 1284 | + testobj = OctocatalogDiff::CatalogDiff::Differ.new(opts, @c1, @c2) |
| 1285 | + testobj.ignore(type: 'Myres', title: 'res1', attr: "parameters\fset2=s>=") |
| 1286 | + result = testobj.diff |
| 1287 | + expect(OctocatalogDiff::Spec.array_contains_partial_array?(result, @set1)).to eq(true) |
| 1288 | + expect(OctocatalogDiff::Spec.array_contains_partial_array?(result, @set2)).to eq(true) |
| 1289 | + expect(OctocatalogDiff::Spec.array_contains_partial_array?(result, @set3)).to eq(true) |
| 1290 | + end |
| 1291 | + |
| 1292 | + it 'should not filter out a change when one array is not specified' do |
| 1293 | + opts = {} |
| 1294 | + testobj = OctocatalogDiff::CatalogDiff::Differ.new(opts, @c1, @c2) |
| 1295 | + testobj.ignore(type: 'Myres', title: 'res1', attr: "parameters\fset3=s>=") |
| 1296 | + result = testobj.diff |
| 1297 | + expect(OctocatalogDiff::Spec.array_contains_partial_array?(result, @set1)).to eq(true) |
| 1298 | + expect(OctocatalogDiff::Spec.array_contains_partial_array?(result, @set2)).to eq(true) |
| 1299 | + expect(OctocatalogDiff::Spec.array_contains_partial_array?(result, @set3)).to eq(true) |
| 1300 | + end |
| 1301 | + end |
| 1302 | + end |
| 1303 | + |
1237 | 1304 | describe '#ignore_match?' do
|
1238 | 1305 | let(:resource) { { type: 'Apple', title: 'delicious', attr: "parameters\fcolor" } }
|
1239 | 1306 | let(:testobj) { described_class.allocate }
|
|
0 commit comments