Skip to content

Commit fbeb740

Browse files
author
Kevin Paulisse
committed
Add coverage for YAML option in differ spec
1 parent 8253f79 commit fbeb740

4 files changed

Lines changed: 68 additions & 1 deletion

File tree

lib/octocatalog-diff/catalog-diff/filter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def self.filter(result, filter_class_name, options = {})
3030
# Inherited: Construct a default `filtered?` method for the subclass via inheritance.
3131
# Each subclass must implement this method, so the default method errors.
3232
def self.filtered?(_item, _options = {})
33-
raise "No `filtered?` method is implemented in #{self.class.name}"
33+
raise "No `filtered?` method is implemented in #{name}"
3434
end
3535
end
3636
end
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"document_type": "Catalog",
3+
"data": {
4+
"tags": ["settings"],
5+
"name": "my.rspec.node",
6+
"version": "production",
7+
"environment": "production",
8+
"resources": [
9+
{
10+
"type": "File",
11+
"title": "/tmp/foo.yaml",
12+
"exported": false,
13+
"parameters": {
14+
"content": "foo:\n bar: baz\n"
15+
}
16+
}
17+
]
18+
},
19+
"metadata": {
20+
"api_version": 1
21+
}
22+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"document_type": "Catalog",
3+
"data": {
4+
"tags": ["settings"],
5+
"name": "my.rspec.node",
6+
"version": "production",
7+
"environment": "production",
8+
"resources": [
9+
{
10+
"type": "File",
11+
"title": "/tmp/foo.yaml",
12+
"exported": false,
13+
"parameters": {
14+
"content": "---\n foo:\n bar: baz\n"
15+
}
16+
}
17+
]
18+
},
19+
"metadata": {
20+
"api_version": 1
21+
}
22+
}

spec/octocatalog-diff/tests/catalog-diff/differ_spec.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,29 @@
662662
end
663663
end
664664

665+
context 'additional pluggable filters' do
666+
context 'equivalent YAML files with different text representations' do
667+
before(:all) do
668+
@c1 = OctocatalogDiff::Catalog.new(json: OctocatalogDiff::Spec.fixture_read('catalogs/ignore-equivalent-yaml-1.json'))
669+
@c2 = OctocatalogDiff::Catalog.new(json: OctocatalogDiff::Spec.fixture_read('catalogs/ignore-equivalent-yaml-2.json'))
670+
end
671+
672+
it 'should filter when filter is enabled' do
673+
opts = { ignore_equivalent_yaml_files: true }
674+
testobj = OctocatalogDiff::CatalogDiff::Differ.new(opts, @c1, @c2)
675+
result = testobj.diff
676+
expect(result.size).to eq(0)
677+
end
678+
679+
it 'should not filter when filter is disabled' do
680+
opts = {}
681+
testobj = OctocatalogDiff::CatalogDiff::Differ.new(opts, @c1, @c2)
682+
result = testobj.diff
683+
expect(result.size).to eq(1)
684+
end
685+
end
686+
end
687+
665688
context 'ignoring specific changes in attributes' do
666689
before(:all) do
667690
@c1 = OctocatalogDiff::Catalog.new(json: OctocatalogDiff::Spec.fixture_read('catalogs/ignore-enhanced-changes-1.json'))

0 commit comments

Comments
 (0)