diff-lcs 1.5.0 → 1.5.1

Sign up to get free protection for your applications and to get access to all the features.
data/spec/change_spec.rb CHANGED
@@ -1,89 +1,89 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  describe Diff::LCS::Change do
6
- describe 'an add' do
7
- subject { described_class.new('+', 0, 'element') }
8
- it { should_not be_deleting }
9
- it { should be_adding }
10
- it { should_not be_unchanged }
11
- it { should_not be_changed }
6
+ describe "an add" do
7
+ subject { described_class.new("+", 0, "element") }
8
+ it { should_not be_deleting }
9
+ it { should be_adding }
10
+ it { should_not be_unchanged }
11
+ it { should_not be_changed }
12
12
  it { should_not be_finished_a }
13
13
  it { should_not be_finished_b }
14
14
  end
15
15
 
16
- describe 'a delete' do
17
- subject { described_class.new('-', 0, 'element') }
18
- it { should be_deleting }
19
- it { should_not be_adding }
20
- it { should_not be_unchanged }
21
- it { should_not be_changed }
16
+ describe "a delete" do
17
+ subject { described_class.new("-", 0, "element") }
18
+ it { should be_deleting }
19
+ it { should_not be_adding }
20
+ it { should_not be_unchanged }
21
+ it { should_not be_changed }
22
22
  it { should_not be_finished_a }
23
23
  it { should_not be_finished_b }
24
24
  end
25
25
 
26
- describe 'an unchanged' do
27
- subject { described_class.new('=', 0, 'element') }
28
- it { should_not be_deleting }
29
- it { should_not be_adding }
30
- it { should be_unchanged }
31
- it { should_not be_changed }
26
+ describe "an unchanged" do
27
+ subject { described_class.new("=", 0, "element") }
28
+ it { should_not be_deleting }
29
+ it { should_not be_adding }
30
+ it { should be_unchanged }
31
+ it { should_not be_changed }
32
32
  it { should_not be_finished_a }
33
33
  it { should_not be_finished_b }
34
34
  end
35
35
 
36
- describe 'a changed' do
37
- subject { described_class.new('!', 0, 'element') }
38
- it { should_not be_deleting }
39
- it { should_not be_adding }
40
- it { should_not be_unchanged }
41
- it { should be_changed }
36
+ describe "a changed" do
37
+ subject { described_class.new("!", 0, "element") }
38
+ it { should_not be_deleting }
39
+ it { should_not be_adding }
40
+ it { should_not be_unchanged }
41
+ it { should be_changed }
42
42
  it { should_not be_finished_a }
43
43
  it { should_not be_finished_b }
44
44
  end
45
45
 
46
- describe 'a finished_a' do
47
- subject { described_class.new('>', 0, 'element') }
48
- it { should_not be_deleting }
49
- it { should_not be_adding }
50
- it { should_not be_unchanged }
51
- it { should_not be_changed }
52
- it { should be_finished_a }
46
+ describe "a finished_a" do
47
+ subject { described_class.new(">", 0, "element") }
48
+ it { should_not be_deleting }
49
+ it { should_not be_adding }
50
+ it { should_not be_unchanged }
51
+ it { should_not be_changed }
52
+ it { should be_finished_a }
53
53
  it { should_not be_finished_b }
54
54
  end
55
55
 
56
- describe 'a finished_b' do
57
- subject { described_class.new('<', 0, 'element') }
58
- it { should_not be_deleting }
59
- it { should_not be_adding }
60
- it { should_not be_unchanged }
61
- it { should_not be_changed }
56
+ describe "a finished_b" do
57
+ subject { described_class.new("<", 0, "element") }
58
+ it { should_not be_deleting }
59
+ it { should_not be_adding }
60
+ it { should_not be_unchanged }
61
+ it { should_not be_changed }
62
62
  it { should_not be_finished_a }
63
- it { should be_finished_b }
63
+ it { should be_finished_b }
64
64
  end
65
65
 
66
- describe 'as array' do
67
- it 'should be converted' do
68
- action, position, element = described_class.new('!', 0, 'element')
69
- expect(action).to eq '!'
66
+ describe "as array" do
67
+ it "should be converted" do
68
+ action, position, element = described_class.new("!", 0, "element")
69
+ expect(action).to eq "!"
70
70
  expect(position).to eq 0
71
- expect(element).to eq 'element'
71
+ expect(element).to eq "element"
72
72
  end
73
73
  end
74
74
  end
75
75
 
76
76
  describe Diff::LCS::ContextChange do
77
- describe 'as array' do
78
- it 'should be converted' do
77
+ describe "as array" do
78
+ it "should be converted" do
79
79
  action, (old_position, old_element), (new_position, new_element) =
80
- described_class.new('!', 1, 'old_element', 2, 'new_element')
80
+ described_class.new("!", 1, "old_element", 2, "new_element")
81
81
 
82
- expect(action).to eq '!'
82
+ expect(action).to eq "!"
83
83
  expect(old_position).to eq 1
84
- expect(old_element).to eq 'old_element'
84
+ expect(old_element).to eq "old_element"
85
85
  expect(new_position).to eq 2
86
- expect(new_element).to eq 'new_element'
86
+ expect(new_element).to eq "new_element"
87
87
  end
88
88
  end
89
89
  end
data/spec/diff_spec.rb CHANGED
@@ -1,28 +1,28 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
- describe Diff::LCS, '.diff' do
5
+ describe Diff::LCS, ".diff" do
6
6
  include Diff::LCS::SpecHelper::Matchers
7
7
 
8
- it 'correctly diffs seq1 to seq2' do
8
+ it "correctly diffs seq1 to seq2" do
9
9
  diff_s1_s2 = Diff::LCS.diff(seq1, seq2)
10
10
  expect(change_diff(correct_forward_diff)).to eq(diff_s1_s2)
11
11
  end
12
12
 
13
- it 'correctly diffs seq2 to seq1' do
13
+ it "correctly diffs seq2 to seq1" do
14
14
  diff_s2_s1 = Diff::LCS.diff(seq2, seq1)
15
15
  expect(change_diff(correct_backward_diff)).to eq(diff_s2_s1)
16
16
  end
17
17
 
18
- it 'correctly diffs against an empty sequence' do
18
+ it "correctly diffs against an empty sequence" do
19
19
  diff = Diff::LCS.diff(word_sequence, [])
20
20
  correct_diff = [
21
21
  [
22
- ['-', 0, 'abcd'],
23
- ['-', 1, 'efgh'],
24
- ['-', 2, 'ijkl'],
25
- ['-', 3, 'mnopqrstuvwxyz']
22
+ ["-", 0, "abcd"],
23
+ ["-", 1, "efgh"],
24
+ ["-", 2, "ijkl"],
25
+ ["-", 3, "mnopqrstuvwxyz"]
26
26
  ]
27
27
  ]
28
28
 
@@ -30,22 +30,22 @@ describe Diff::LCS, '.diff' do
30
30
 
31
31
  diff = Diff::LCS.diff([], word_sequence)
32
32
  correct_diff.each do |hunk|
33
- hunk.each do |change| change[0] = '+' end
33
+ hunk.each { |change| change[0] = "+" }
34
34
  end
35
35
  expect(change_diff(correct_diff)).to eq(diff)
36
36
  end
37
37
 
38
38
  it "correctly diffs 'xx' and 'xaxb'" do
39
- left = 'xx'
40
- right = 'xaxb'
39
+ left = "xx"
40
+ right = "xaxb"
41
41
  expect(Diff::LCS.patch(left, Diff::LCS.diff(left, right))).to eq(right)
42
42
  end
43
43
 
44
- it 'returns an empty diff with (hello, hello)' do
44
+ it "returns an empty diff with (hello, hello)" do
45
45
  expect(Diff::LCS.diff(hello, hello)).to be_empty
46
46
  end
47
47
 
48
- it 'returns an empty diff with (hello_ary, hello_ary)' do
48
+ it "returns an empty diff with (hello_ary, hello_ary)" do
49
49
  expect(Diff::LCS.diff(hello_ary, hello_ary)).to be_empty
50
50
  end
51
51
  end
data/spec/hunk_spec.rb CHANGED
@@ -1,18 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  if String.method_defined?(:encoding)
6
- require 'diff/lcs/hunk'
6
+ require "diff/lcs/hunk"
7
7
 
8
8
  describe Diff::LCS::Hunk do
9
- let(:old_data) { ['Tu a un carté avec {count} itéms'.encode('UTF-16LE')] }
10
- let(:new_data) { ['Tu a un carte avec {count} items'.encode('UTF-16LE')] }
11
- let(:pieces) { Diff::LCS.diff old_data, new_data }
12
- let(:hunk) { Diff::LCS::Hunk.new(old_data, new_data, pieces[0], 3, 0) }
9
+ let(:old_data) { ["Tu a un carté avec {count} itéms".encode("UTF-16LE")] }
10
+ let(:new_data) { ["Tu a un carte avec {count} items".encode("UTF-16LE")] }
11
+ let(:pieces) { Diff::LCS.diff old_data, new_data }
12
+ let(:hunk) { Diff::LCS::Hunk.new(old_data, new_data, pieces[0], 3, 0) }
13
13
 
14
- it 'produces a unified diff from the two pieces' do
15
- expected = <<-EXPECTED.gsub(/^\s+/, '').encode('UTF-16LE').chomp
14
+ it "produces a unified diff from the two pieces" do
15
+ expected = <<-EXPECTED.gsub(/^\s+/, "").encode("UTF-16LE").chomp
16
16
  @@ -1 +1 @@
17
17
  -Tu a un carté avec {count} itéms
18
18
  +Tu a un carte avec {count} items
@@ -21,8 +21,8 @@ if String.method_defined?(:encoding)
21
21
  expect(hunk.diff(:unified)).to eq(expected)
22
22
  end
23
23
 
24
- it 'produces a unified diff from the two pieces (last entry)' do
25
- expected = <<-EXPECTED.gsub(/^\s+/, '').encode('UTF-16LE').chomp
24
+ it "produces a unified diff from the two pieces (last entry)" do
25
+ expected = <<-EXPECTED.gsub(/^\s+/, "").encode("UTF-16LE").chomp
26
26
  @@ -1 +1 @@
27
27
  -Tu a un carté avec {count} itéms
28
28
  +Tu a un carte avec {count} items
@@ -32,8 +32,8 @@ if String.method_defined?(:encoding)
32
32
  expect(hunk.diff(:unified, true)).to eq(expected)
33
33
  end
34
34
 
35
- it 'produces a context diff from the two pieces' do
36
- expected = <<-EXPECTED.gsub(/^\s+/, '').encode('UTF-16LE').chomp
35
+ it "produces a context diff from the two pieces" do
36
+ expected = <<-EXPECTED.gsub(/^\s+/, "").encode("UTF-16LE").chomp
37
37
  ***************
38
38
  *** 1 ****
39
39
  ! Tu a un carté avec {count} itéms
@@ -44,8 +44,8 @@ if String.method_defined?(:encoding)
44
44
  expect(hunk.diff(:context)).to eq(expected)
45
45
  end
46
46
 
47
- it 'produces an old diff from the two pieces' do
48
- expected = <<-EXPECTED.gsub(/^ +/, '').encode('UTF-16LE').chomp
47
+ it "produces an old diff from the two pieces" do
48
+ expected = <<-EXPECTED.gsub(/^ +/, "").encode("UTF-16LE").chomp
49
49
  1c1
50
50
  < Tu a un carté avec {count} itéms
51
51
  ---
@@ -56,8 +56,8 @@ if String.method_defined?(:encoding)
56
56
  expect(hunk.diff(:old)).to eq(expected)
57
57
  end
58
58
 
59
- it 'produces a reverse ed diff from the two pieces' do
60
- expected = <<-EXPECTED.gsub(/^ +/, '').encode('UTF-16LE').chomp
59
+ it "produces a reverse ed diff from the two pieces" do
60
+ expected = <<-EXPECTED.gsub(/^ +/, "").encode("UTF-16LE").chomp
61
61
  c1
62
62
  Tu a un carte avec {count} items
63
63
  .
@@ -67,11 +67,11 @@ if String.method_defined?(:encoding)
67
67
  expect(hunk.diff(:reverse_ed)).to eq(expected)
68
68
  end
69
69
 
70
- context 'with empty first data set' do
70
+ context "with empty first data set" do
71
71
  let(:old_data) { [] }
72
72
 
73
- it 'produces a unified diff' do
74
- expected = <<-EXPECTED.gsub(/^\s+/, '').encode('UTF-16LE').chomp
73
+ it "produces a unified diff" do
74
+ expected = <<-EXPECTED.gsub(/^\s+/, "").encode("UTF-16LE").chomp
75
75
  @@ -1 +1,2 @@
76
76
  +Tu a un carte avec {count} items
77
77
  EXPECTED
data/spec/issues_spec.rb CHANGED
@@ -1,73 +1,76 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
4
- require 'diff/lcs/hunk'
3
+ require "spec_helper"
4
+ require "diff/lcs/hunk"
5
5
 
6
- describe 'Diff::LCS Issues' do
6
+ describe "Diff::LCS Issues" do
7
7
  include Diff::LCS::SpecHelper::Matchers
8
8
 
9
- describe 'issue #1' do
10
- shared_examples 'handles simple diffs' do |s1, s2, forward_diff|
9
+ describe "issue #1" do
10
+ shared_examples "handles simple diffs" do |s1, s2, forward_diff|
11
11
  before do
12
12
  @diff_s1_s2 = Diff::LCS.diff(s1, s2)
13
13
  end
14
14
 
15
- it 'creates the correct diff' do
15
+ it "creates the correct diff" do
16
16
  expect(change_diff(forward_diff)).to eq(@diff_s1_s2)
17
17
  end
18
18
 
19
- it 'creates the correct patch s1->s2' do
19
+ it "creates the correct patch s1->s2" do
20
20
  expect(Diff::LCS.patch(s1, @diff_s1_s2)).to eq(s2)
21
21
  end
22
22
 
23
- it 'creates the correct patch s2->s1' do
23
+ it "creates the correct patch s2->s1" do
24
24
  expect(Diff::LCS.patch(s2, @diff_s1_s2)).to eq(s1)
25
25
  end
26
26
  end
27
27
 
28
- describe 'string' do
29
- it_has_behavior 'handles simple diffs', 'aX', 'bXaX', [
28
+ describe "string" do
29
+ it_has_behavior "handles simple diffs", "aX", "bXaX", [
30
30
  [
31
- ['+', 0, 'b'],
32
- ['+', 1, 'X']
31
+ ["+", 0, "b"],
32
+ ["+", 1, "X"]
33
33
  ]
34
34
  ]
35
- it_has_behavior 'handles simple diffs', 'bXaX', 'aX', [
35
+ it_has_behavior "handles simple diffs", "bXaX", "aX", [
36
36
  [
37
- ['-', 0, 'b'],
38
- ['-', 1, 'X']
37
+ ["-", 0, "b"],
38
+ ["-", 1, "X"]
39
39
  ]
40
40
  ]
41
41
  end
42
42
 
43
- describe 'array' do
44
- it_has_behavior 'handles simple diffs', %w(a X), %w(b X a X), [
43
+ describe "array" do
44
+ it_has_behavior "handles simple diffs", %w[a X], %w[b X a X], [
45
45
  [
46
- ['+', 0, 'b'],
47
- ['+', 1, 'X']
46
+ ["+", 0, "b"],
47
+ ["+", 1, "X"]
48
48
  ]
49
49
  ]
50
- it_has_behavior 'handles simple diffs', %w(b X a X), %w(a X), [
50
+ it_has_behavior "handles simple diffs", %w[b X a X], %w[a X], [
51
51
  [
52
- ['-', 0, 'b'],
53
- ['-', 1, 'X']
52
+ ["-", 0, "b"],
53
+ ["-", 1, "X"]
54
54
  ]
55
55
  ]
56
56
  end
57
57
  end
58
58
 
59
- describe 'issue #57' do
60
- it 'should fail with a correct error' do
59
+ describe "issue #57" do
60
+ it "should fail with a correct error" do
61
+ # standard:disable Style/HashSyntax
61
62
  expect {
62
- actual = { :category => 'app.rack.request' }
63
- expected = { :category => 'rack.middleware', :title => 'Anonymous Middleware' }
63
+ actual = {:category => "app.rack.request"}
64
+ expected = {:category => "rack.middleware", :title => "Anonymous Middleware"}
64
65
  expect(actual).to eq(expected)
65
66
  }.to raise_error(RSpec::Expectations::ExpectationNotMetError)
67
+ # standard:enable Style/HashSyntax
66
68
  end
67
69
  end
68
70
 
69
- describe 'issue #60' do
70
- it 'should produce unified output with correct context' do
71
+ describe "issue #60" do
72
+ it "should produce unified output with correct context" do
73
+ # standard:disable Layout/HeredocIndentation
71
74
  old_data = <<-DATA_OLD.strip.split("\n").map(&:chomp)
72
75
  {
73
76
  "name": "x",
@@ -93,10 +96,11 @@ describe 'Diff::LCS Issues' do
93
96
  + "description": "lo"
94
97
  }
95
98
  EXPECTED
99
+ # standard:enable Layout/HeredocIndentation
96
100
  end
97
101
  end
98
102
 
99
- describe 'issue #65' do
103
+ describe "issue #65" do
100
104
  def diff_lines(old_lines, new_lines)
101
105
  file_length_difference = 0
102
106
  previous_hunk = nil
@@ -105,7 +109,7 @@ describe 'Diff::LCS Issues' do
105
109
  Diff::LCS.diff(old_lines, new_lines).each do |piece|
106
110
  hunk = Diff::LCS::Hunk.new(old_lines, new_lines, piece, 3, file_length_difference)
107
111
  file_length_difference = hunk.file_length_difference
108
- maybe_contiguous_hunks = (previous_hunk.nil? || hunk.merge(previous_hunk))
112
+ maybe_contiguous_hunks = previous_hunk.nil? || hunk.merge(previous_hunk)
109
113
 
110
114
  output << "#{previous_hunk.diff(:unified)}\n" unless maybe_contiguous_hunks
111
115
 
@@ -115,24 +119,25 @@ describe 'Diff::LCS Issues' do
115
119
  output.join
116
120
  end
117
121
 
118
- it 'should not misplace the new chunk' do
122
+ it "should not misplace the new chunk" do
119
123
  old_data = [
120
- 'recipe[a::default]', 'recipe[b::default]', 'recipe[c::default]',
121
- 'recipe[d::default]', 'recipe[e::default]', 'recipe[f::default]',
122
- 'recipe[g::default]', 'recipe[h::default]', 'recipe[i::default]',
123
- 'recipe[j::default]', 'recipe[k::default]', 'recipe[l::default]',
124
- 'recipe[m::default]', 'recipe[n::default]'
124
+ "recipe[a::default]", "recipe[b::default]", "recipe[c::default]",
125
+ "recipe[d::default]", "recipe[e::default]", "recipe[f::default]",
126
+ "recipe[g::default]", "recipe[h::default]", "recipe[i::default]",
127
+ "recipe[j::default]", "recipe[k::default]", "recipe[l::default]",
128
+ "recipe[m::default]", "recipe[n::default]"
125
129
  ]
126
130
 
127
131
  new_data = [
128
- 'recipe[a::default]', 'recipe[c::default]', 'recipe[d::default]',
129
- 'recipe[e::default]', 'recipe[f::default]', 'recipe[g::default]',
130
- 'recipe[h::default]', 'recipe[i::default]', 'recipe[j::default]',
131
- 'recipe[k::default]', 'recipe[l::default]', 'recipe[m::default]',
132
- 'recipe[n::default]', 'recipe[o::new]', 'recipe[p::new]',
133
- 'recipe[q::new]', 'recipe[r::new]'
132
+ "recipe[a::default]", "recipe[c::default]", "recipe[d::default]",
133
+ "recipe[e::default]", "recipe[f::default]", "recipe[g::default]",
134
+ "recipe[h::default]", "recipe[i::default]", "recipe[j::default]",
135
+ "recipe[k::default]", "recipe[l::default]", "recipe[m::default]",
136
+ "recipe[n::default]", "recipe[o::new]", "recipe[p::new]",
137
+ "recipe[q::new]", "recipe[r::new]"
134
138
  ]
135
139
 
140
+ # standard:disable Layout/HeredocIndentation
136
141
  expect(diff_lines(old_data, new_data)).to eq(<<-EODIFF)
137
142
  @@ -1,5 +1,4 @@
138
143
  recipe[a::default]
@@ -149,6 +154,7 @@ describe 'Diff::LCS Issues' do
149
154
  +recipe[q::new]
150
155
  +recipe[r::new]
151
156
  EODIFF
157
+ # standard:enable Layout/HeredocIndentation
152
158
  end
153
159
  end
154
160
  end
data/spec/lcs_spec.rb CHANGED
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
- describe Diff::LCS::Internals, '.lcs' do
5
+ describe Diff::LCS::Internals, ".lcs" do
6
6
  include Diff::LCS::SpecHelper::Matchers
7
7
 
8
- it 'returns a meaningful LCS array with (seq1, seq2)' do
8
+ it "returns a meaningful LCS array with (seq1, seq2)" do
9
9
  res = Diff::LCS::Internals.lcs(seq1, seq2)
10
10
  # The result of the LCS (less the +nil+ values) must be as long as the
11
11
  # correct result.
@@ -20,37 +20,37 @@ describe Diff::LCS::Internals, '.lcs' do
20
20
  expect(x_seq2).to eq(correct_lcs)
21
21
  end
22
22
 
23
- it 'returns all indexes with (hello, hello)' do
23
+ it "returns all indexes with (hello, hello)" do
24
24
  expect(Diff::LCS::Internals.lcs(hello, hello)).to \
25
25
  eq((0...hello.size).to_a)
26
26
  end
27
27
 
28
- it 'returns all indexes with (hello_ary, hello_ary)' do
28
+ it "returns all indexes with (hello_ary, hello_ary)" do
29
29
  expect(Diff::LCS::Internals.lcs(hello_ary, hello_ary)).to \
30
30
  eq((0...hello_ary.size).to_a)
31
31
  end
32
32
  end
33
33
 
34
- describe Diff::LCS, '.LCS' do
34
+ describe Diff::LCS, ".LCS" do
35
35
  include Diff::LCS::SpecHelper::Matchers
36
36
 
37
- it 'returns the correct compacted values from Diff::LCS.LCS' do
37
+ it "returns the correct compacted values from Diff::LCS.LCS" do
38
38
  res = Diff::LCS.LCS(seq1, seq2)
39
39
  expect(res).to eq(correct_lcs)
40
40
  expect(res.compact).to eq(res)
41
41
  end
42
42
 
43
- it 'is transitive' do
43
+ it "is transitive" do
44
44
  res = Diff::LCS.LCS(seq2, seq1)
45
45
  expect(res).to eq(correct_lcs)
46
46
  expect(res.compact).to eq(res)
47
47
  end
48
48
 
49
- it 'returns %W(h e l l o) with (hello, hello)' do
50
- expect(Diff::LCS.LCS(hello, hello)).to eq(hello.split(//))
49
+ it "returns %W(h e l l o) with (hello, hello)" do
50
+ expect(Diff::LCS.LCS(hello, hello)).to eq(hello.chars)
51
51
  end
52
52
 
53
- it 'returns hello_ary with (hello_ary, hello_ary)' do
53
+ it "returns hello_ary with (hello_ary, hello_ary)" do
54
54
  expect(Diff::LCS.LCS(hello_ary, hello_ary)).to eq(hello_ary)
55
55
  end
56
56
  end
data/spec/ldiff_spec.rb CHANGED
@@ -1,29 +1,31 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
- RSpec.describe 'bin/ldiff' do
5
+ RSpec.describe "bin/ldiff" do
6
6
  include CaptureSubprocessIO
7
7
 
8
+ # standard:disable Style/HashSyntax
8
9
  fixtures = [
9
- { :name => 'output.diff', :left => 'aX', :right => 'bXaX' },
10
- { :name => 'output.diff.chef', :left => 'old-chef', :right => 'new-chef' },
11
- { :name => 'output.diff.chef2', :left => 'old-chef2', :right => 'new-chef2' }
12
- ].product([nil, '-e', '-f', '-c', '-u']).map { |(fixture, flag)|
10
+ {:name => "output.diff", :left => "aX", :right => "bXaX"},
11
+ {:name => "output.diff.chef", :left => "old-chef", :right => "new-chef"},
12
+ {:name => "output.diff.chef2", :left => "old-chef2", :right => "new-chef2"}
13
+ ].product([nil, "-e", "-f", "-c", "-u"]).map { |(fixture, flag)|
13
14
  fixture = fixture.dup
14
15
  fixture[:flag] = flag
15
16
  fixture
16
17
  }
18
+ # standard:enable Style/HashSyntax
17
19
 
18
20
  def self.test_ldiff(fixture)
19
21
  desc = [
20
22
  fixture[:flag],
21
23
  "spec/fixtures/#{fixture[:left]}",
22
24
  "spec/fixtures/#{fixture[:right]}",
23
- '#',
24
- '=>',
25
+ "#",
26
+ "=>",
25
27
  "spec/fixtures/ldiff/#{fixture[:name]}#{fixture[:flag]}"
26
- ].join(' ')
28
+ ].join(" ")
27
29
 
28
30
  it desc do
29
31
  expect(run_ldiff(fixture)).to eq(read_fixture(fixture))
@@ -45,7 +47,7 @@ RSpec.describe 'bin/ldiff' do
45
47
  def clean_data(data, flag)
46
48
  data =
47
49
  case flag
48
- when '-c', '-u'
50
+ when "-c", "-u"
49
51
  clean_output_timestamp(data)
50
52
  else
51
53
  data
@@ -80,7 +82,7 @@ RSpec.describe 'bin/ldiff' do
80
82
  system("ruby -Ilib bin/ldiff #{flag} spec/fixtures/#{left} spec/fixtures/#{right}")
81
83
  end
82
84
 
83
- expect(stderr).to be_empty if RUBY_VERSION >= '1.9'
85
+ expect(stderr).to be_empty if RUBY_VERSION >= "1.9"
84
86
  expect(stdout).not_to be_empty
85
87
  clean_data(stdout, flag)
86
88
  end