|
4 | 4 | require 'json' |
5 | 5 |
|
6 | 6 | describe 'YAML file suppression for identical diffs' do |
7 | | - let(:argv) { ['-n', 'rspec-node.github.net', '--to-fact-override', 'role=bar'] } |
8 | | - let(:hash) do |
9 | | - { |
10 | | - hiera_config: 'hiera.yaml', |
11 | | - spec_fact_file: 'facts.yaml', |
12 | | - spec_repo: 'yaml-diff' |
13 | | - } |
14 | | - end |
15 | | - |
16 | 7 | context 'with YAML diff suppression disabled' do |
17 | | - let(:result) { OctocatalogDiff::Integration.integration(hash.merge(argv: argv)) } |
| 8 | + before(:all) do |
| 9 | + argv = ['-n', 'rspec-node.github.net', '--to-fact-override', 'role=bar'] |
| 10 | + hash = { hiera_config: 'hiera.yaml', spec_fact_file: 'facts.yaml', spec_repo: 'yaml-diff' } |
| 11 | + @result = OctocatalogDiff::Integration.integration(hash.merge(argv: argv)) |
| 12 | + end |
18 | 13 |
|
19 | 14 | it 'should compile without error' do |
20 | | - expect(result.exitcode).to eq(2), OctocatalogDiff::Integration.format_exception(result) |
21 | | - expect(result.exception).to be_nil |
| 15 | + expect(@result.exitcode).to eq(2), OctocatalogDiff::Integration.format_exception(@result) |
| 16 | + expect(@result.exception).to be_nil |
| 17 | + end |
| 18 | + |
| 19 | + it 'should contain the correct number of diffs' do |
| 20 | + expect(@result.diffs.size).to eq(22) |
| 21 | + end |
| 22 | + |
| 23 | + it 'should contain the "similar JSON" static file as a diff' do |
| 24 | + arr = @result.diffs |
| 25 | + answer = ['~', "File\f/tmp/static/similar-yaml.json\fparameters\fcontent"] |
| 26 | + expect(OctocatalogDiff::Spec.array_contains_partial_array?(arr, answer)).to eq(true) |
| 27 | + end |
| 28 | + |
| 29 | + it 'should contain the "similar YAML" static file as a diff' do |
| 30 | + arr = @result.diffs |
| 31 | + answer = ['~', "File\f/tmp/static/similar-yaml.yaml\fparameters\fcontent"] |
| 32 | + expect(OctocatalogDiff::Spec.array_contains_partial_array?(arr, answer)).to eq(true) |
| 33 | + end |
| 34 | + |
| 35 | + it 'should contain the "similar JSON" template file as a diff' do |
| 36 | + arr = @result.diffs |
| 37 | + answer = ['~', "File\f/tmp/template/similar-yaml.json\fparameters\fcontent"] |
| 38 | + expect(OctocatalogDiff::Spec.array_contains_partial_array?(arr, answer)).to eq(true) |
| 39 | + end |
| 40 | + |
| 41 | + it 'should contain the "similar YAML" template file as a diff' do |
| 42 | + arr = @result.diffs |
| 43 | + answer = ['~', "File\f/tmp/template/similar-yaml.yaml\fparameters\fcontent"] |
| 44 | + expect(OctocatalogDiff::Spec.array_contains_partial_array?(arr, answer)).to eq(true) |
22 | 45 | end |
23 | 46 | end |
24 | 47 |
|
25 | 48 | context 'with YAML diff suppression enabled' do |
26 | | - let(:result) { OctocatalogDiff::Integration.integration(hash.merge(argv: argv + ['--ignore-yaml-whitespace'])) } |
| 49 | + before(:all) do |
| 50 | + argv = ['-n', 'rspec-node.github.net', '--to-fact-override', 'role=bar', '--ignore-equivalent-yaml-files'] |
| 51 | + hash = { hiera_config: 'hiera.yaml', spec_fact_file: 'facts.yaml', spec_repo: 'yaml-diff' } |
| 52 | + @result = OctocatalogDiff::Integration.integration(hash.merge(argv: argv)) |
| 53 | + end |
27 | 54 |
|
28 | 55 | it 'should compile without error' do |
29 | | - expect(result.exitcode).to eq(2), OctocatalogDiff::Integration.format_exception(result) |
30 | | - expect(result.exception).to be_nil |
| 56 | + expect(@result.exitcode).to eq(2), OctocatalogDiff::Integration.format_exception(@result) |
| 57 | + expect(@result.exception).to be_nil |
| 58 | + end |
| 59 | + |
| 60 | + it 'should contain the correct number of diffs' do |
| 61 | + expect(@result.diffs.size).to eq(20) |
| 62 | + end |
| 63 | + |
| 64 | + it 'should contain the "similar JSON" static file as a diff' do |
| 65 | + arr = @result.diffs |
| 66 | + answer = ['~', "File\f/tmp/static/similar-yaml.json\fparameters\fcontent"] |
| 67 | + expect(OctocatalogDiff::Spec.array_contains_partial_array?(arr, answer)).to eq(true) |
| 68 | + end |
| 69 | + |
| 70 | + it 'should not contain the "similar YAML" static file as a diff' do |
| 71 | + arr = @result.diffs |
| 72 | + answer = ['~', "File\f/tmp/static/similar-yaml.yaml\fparameters\fcontent"] |
| 73 | + expect(OctocatalogDiff::Spec.array_contains_partial_array?(arr, answer)).to eq(false) |
| 74 | + end |
| 75 | + |
| 76 | + it 'should contain the "similar JSON" template file as a diff' do |
| 77 | + arr = @result.diffs |
| 78 | + answer = ['~', "File\f/tmp/template/similar-yaml.json\fparameters\fcontent"] |
| 79 | + expect(OctocatalogDiff::Spec.array_contains_partial_array?(arr, answer)).to eq(true) |
| 80 | + end |
| 81 | + |
| 82 | + it 'should not contain the "similar YAML" template file as a diff' do |
| 83 | + arr = @result.diffs |
| 84 | + answer = ['~', "File\f/tmp/template/similar-yaml.yaml\fparameters\fcontent"] |
| 85 | + expect(OctocatalogDiff::Spec.array_contains_partial_array?(arr, answer)).to eq(false) |
31 | 86 | end |
32 | 87 | end |
33 | 88 | end |
0 commit comments