diff-lcs 1.3 → 1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1 @@
1
+ aX
@@ -0,0 +1 @@
1
+ bXaX
@@ -0,0 +1,4 @@
1
+ 1c1
2
+ < aX
3
+ ---
4
+ > bXaX
@@ -0,0 +1,7 @@
1
+ *** spec/fixtures/aX 2019-02-01 22:29:34.000000000 -0500
2
+ --- spec/fixtures/bXaX 2019-02-01 22:29:43.000000000 -0500
3
+ ***************
4
+ *** 1 ****
5
+ ! aX
6
+ --- 1 ----
7
+ ! bXaX
@@ -0,0 +1,3 @@
1
+ 1c
2
+ bXaX
3
+ .
@@ -0,0 +1,3 @@
1
+ c1
2
+ bXaX
3
+ .
@@ -0,0 +1,5 @@
1
+ --- spec/fixtures/aX 2019-02-01 22:29:34.000000000 -0500
2
+ +++ spec/fixtures/bXaX 2019-02-01 22:29:43.000000000 -0500
3
+ @@ -1 +1 @@
4
+ -aX
5
+ +bXaX
@@ -1,4 +1,4 @@
1
- # -*- ruby encoding: utf-8 -*-
1
+ # frozen_string_literal: true
2
2
 
3
3
  require 'spec_helper'
4
4
 
@@ -6,52 +6,52 @@ if String.method_defined?(:encoding)
6
6
  require 'diff/lcs/hunk'
7
7
 
8
8
  describe Diff::LCS::Hunk do
9
- let(:old_data) { ["Tu avec carté {count} itém has".encode('UTF-16LE')] }
10
- let(:new_data) { ["Tu avec carte {count} item has".encode('UTF-16LE')] }
9
+ let(:old_data) { ['Tu avec carté {count} itém has'.encode('UTF-16LE')] }
10
+ let(:new_data) { ['Tu avec carte {count} item has'.encode('UTF-16LE')] }
11
11
  let(:pieces) { Diff::LCS.diff old_data, new_data }
12
12
  let(:hunk) { Diff::LCS::Hunk.new(old_data, new_data, pieces[0], 3, 0) }
13
13
 
14
14
  it 'produces a unified diff from the two pieces' do
15
- expected = (<<-EOD.gsub(/^\s+/,'').encode('UTF-16LE').chomp)
16
- @@ -1,2 +1,2 @@
15
+ expected = <<-EXPECTED.gsub(/^\s+/, '').encode('UTF-16LE').chomp
16
+ @@ -1 +1 @@
17
17
  -Tu avec carté {count} itém has
18
18
  +Tu avec carte {count} item has
19
- EOD
19
+ EXPECTED
20
20
 
21
21
  expect(hunk.diff(:unified)).to eq(expected)
22
22
  end
23
23
 
24
24
  it 'produces a context diff from the two pieces' do
25
- expected = (<<-EOD.gsub(/^\s+/,'').encode('UTF-16LE').chomp)
25
+ expected = <<-EXPECTED.gsub(/^\s+/, '').encode('UTF-16LE').chomp
26
26
  ***************
27
- *** 1,2 ****
28
- !Tu avec carté {count} itém has
29
- --- 1,2 ----
30
- !Tu avec carte {count} item has
31
- EOD
27
+ *** 1 ****
28
+ ! Tu avec carté {count} itém has
29
+ --- 1 ----
30
+ ! Tu avec carte {count} item has
31
+ EXPECTED
32
32
 
33
33
  expect(hunk.diff(:context)).to eq(expected)
34
34
  end
35
35
 
36
36
  it 'produces an old diff from the two pieces' do
37
- expected = (<<-EOD.gsub(/^ +/,'').encode('UTF-16LE').chomp)
38
- 1,2c1,2
37
+ expected = <<-EXPECTED.gsub(/^ +/, '').encode('UTF-16LE').chomp
38
+ 1c1
39
39
  < Tu avec carté {count} itém has
40
40
  ---
41
41
  > Tu avec carte {count} item has
42
42
 
43
- EOD
43
+ EXPECTED
44
44
 
45
45
  expect(hunk.diff(:old)).to eq(expected)
46
46
  end
47
47
 
48
48
  it 'produces a reverse ed diff from the two pieces' do
49
- expected = (<<-EOD.gsub(/^ +/,'').encode('UTF-16LE').chomp)
50
- c1,2
49
+ expected = <<-EXPECTED.gsub(/^ +/, '').encode('UTF-16LE').chomp
50
+ c1
51
51
  Tu avec carte {count} item has
52
52
  .
53
53
 
54
- EOD
54
+ EXPECTED
55
55
 
56
56
  expect(hunk.diff(:reverse_ed)).to eq(expected)
57
57
  end
@@ -60,10 +60,10 @@ if String.method_defined?(:encoding)
60
60
  let(:old_data) { [] }
61
61
 
62
62
  it 'produces a unified diff' do
63
- expected = (<<-EOD.gsub(/^\s+/,'').encode('UTF-16LE').chomp)
63
+ expected = <<-EXPECTED.gsub(/^\s+/, '').encode('UTF-16LE').chomp
64
64
  @@ -1 +1,2 @@
65
65
  +Tu avec carte {count} item has
66
- EOD
66
+ EXPECTED
67
67
 
68
68
  expect(hunk.diff(:unified)).to eq(expected)
69
69
  end
@@ -1,8 +1,8 @@
1
- # -*- ruby encoding: utf-8 -*-
1
+ # frozen_string_literal: true
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe "Diff::LCS Issues" do
5
+ describe 'Diff::LCS Issues' do
6
6
  include Diff::LCS::SpecHelper::Matchers
7
7
 
8
8
  describe 'issue #1' do
@@ -26,23 +26,31 @@ describe "Diff::LCS Issues" do
26
26
 
27
27
  describe 'string' do
28
28
  it_has_behavior 'handles simple diffs', 'aX', 'bXaX', [
29
- [ [ '+', 0, 'b' ],
30
- [ '+', 1, 'X' ] ],
29
+ [
30
+ ['+', 0, 'b'],
31
+ ['+', 1, 'X']
32
+ ]
31
33
  ]
32
34
  it_has_behavior 'handles simple diffs', 'bXaX', 'aX', [
33
- [ [ '-', 0, 'b' ],
34
- [ '-', 1, 'X' ] ],
35
+ [
36
+ ['-', 0, 'b'],
37
+ ['-', 1, 'X']
38
+ ]
35
39
  ]
36
40
  end
37
41
 
38
42
  describe 'array' do
39
43
  it_has_behavior 'handles simple diffs', %w(a X), %w(b X a X), [
40
- [ [ '+', 0, 'b' ],
41
- [ '+', 1, 'X' ] ],
44
+ [
45
+ ['+', 0, 'b'],
46
+ ['+', 1, 'X']
47
+ ]
42
48
  ]
43
49
  it_has_behavior 'handles simple diffs', %w(b X a X), %w(a X), [
44
- [ [ '-', 0, 'b' ],
45
- [ '-', 1, 'X' ] ],
50
+ [
51
+ ['-', 0, 'b'],
52
+ ['-', 1, 'X']
53
+ ]
46
54
  ]
47
55
  end
48
56
  end
@@ -1,11 +1,11 @@
1
- # -*- ruby encoding: utf-8 -*-
1
+ # frozen_string_literal: true
2
2
 
3
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
49
+ it 'returns %W(h e l l o) with (hello, hello)' do
50
50
  expect(Diff::LCS.LCS(hello, hello)).to eq(hello.split(//))
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
@@ -1,47 +1,72 @@
1
- # -*- ruby encoding: utf-8 -*-
1
+ # frozen_string_literal: true
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe "Diff::LCS.diff" do
6
- include Diff::LCS::SpecHelper::Matchers
5
+ RSpec.describe 'bin/ldiff' do
6
+ include CaptureSubprocessIO
7
7
 
8
- it 'correctly diffs seq1 to seq2' do
9
- diff_s1_s2 = Diff::LCS.diff(seq1, seq2)
10
- expect(change_diff(correct_forward_diff)).to eq(diff_s1_s2)
8
+ let(:output_diff) { read_fixture }
9
+ let(:output_diff_c) { read_fixture('-c') }
10
+ let(:output_diff_e) { read_fixture('-e') }
11
+ let(:output_diff_f) { read_fixture('-f') }
12
+ let(:output_diff_u) { read_fixture('-u') }
13
+
14
+ specify do
15
+ expect(run_ldiff).to eq(output_diff)
11
16
  end
12
17
 
13
- it 'correctly diffs seq2 to seq1' do
14
- diff_s2_s1 = Diff::LCS.diff(seq2, seq1)
15
- expect(change_diff(correct_backward_diff)).to eq(diff_s2_s1)
18
+ specify do
19
+ expect(run_ldiff('-c')).to eq(output_diff_c)
16
20
  end
17
21
 
18
- it 'correctly diffs against an empty sequence' do
19
- diff = Diff::LCS.diff(word_sequence, [])
20
- correct_diff = [
21
- [ [ '-', 0, 'abcd' ],
22
- [ '-', 1, 'efgh' ],
23
- [ '-', 2, 'ijkl' ],
24
- [ '-', 3, 'mnopqrstuvwxyz' ] ]
25
- ]
22
+ specify do
23
+ expect(run_ldiff('-e')).to eq(output_diff_e)
24
+ end
26
25
 
27
- expect(change_diff(correct_diff)).to eq(diff)
26
+ specify do
27
+ expect(run_ldiff('-f')).to eq(output_diff_f)
28
+ end
29
+
30
+ specify do
31
+ expect(run_ldiff('-u')).to eq(output_diff_u)
32
+ end
28
33
 
29
- diff = Diff::LCS.diff([], word_sequence)
30
- correct_diff.each { |hunk| hunk.each { |change| change[0] = '+' } }
31
- expect(change_diff(correct_diff)).to eq(diff)
34
+ def read_fixture(flag = nil)
35
+ clean_data(IO.binread("spec/fixtures/ldiff/output.diff#{flag}"), flag)
32
36
  end
33
37
 
34
- it "correctly diffs 'xx' and 'xaxb'" do
35
- left = 'xx'
36
- right = 'xaxb'
37
- expect(Diff::LCS.patch(left, Diff::LCS.diff(left, right))).to eq(right)
38
+ def clean_data(data, flag)
39
+ case flag
40
+ when '-c', '-u'
41
+ clean_output_timestamp(data)
42
+ else
43
+ data
44
+ end
38
45
  end
39
46
 
40
- it "returns an empty diff with (hello, hello)" do
41
- expect(Diff::LCS.diff(hello, hello)).to eq([])
47
+ def clean_output_timestamp(data)
48
+ data.gsub(
49
+ %r{
50
+ [-*+]{3}
51
+ \s
52
+ spec/fixtures/(\w+)
53
+ \s
54
+ \d{4}-\d\d-\d\d
55
+ \s
56
+ \d\d:\d\d:\d\d(?:\.\d+)
57
+ \s
58
+ (?:[-+]\d{4}|Z)
59
+ }x,
60
+ '*** spec/fixtures/\1 0000-00-00 00:00:00.000000000 -0000'
61
+ )
42
62
  end
43
63
 
44
- it "returns an empty diff with (hello_ary, hello_ary)" do
45
- expect(Diff::LCS.diff(hello_ary, hello_ary)).to eq([])
64
+ def run_ldiff(flag = nil, left: 'aX', right: 'bXaX')
65
+ stdout, stderr = capture_subprocess_io do
66
+ system("ruby -Ilib bin/ldiff #{flag} spec/fixtures/#{left} spec/fixtures/#{right}")
67
+ end
68
+ expect(stderr).to be_empty
69
+ expect(stdout).not_to be_empty
70
+ clean_data(stdout, flag)
46
71
  end
47
72
  end
@@ -1,54 +1,54 @@
1
- # -*- ruby encoding: utf-8 -*-
1
+ # frozen_string_literal: true
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe "Diff::LCS.patch" do
5
+ describe 'Diff::LCS.patch' do
6
6
  include Diff::LCS::SpecHelper::Matchers
7
7
 
8
- shared_examples "patch sequences correctly" do
9
- it "correctly patches left-to-right (patch autodiscovery)" do
8
+ shared_examples 'patch sequences correctly' do
9
+ it 'correctly patches left-to-right (patch autodiscovery)' do
10
10
  expect(Diff::LCS.patch(s1, patch_set)).to eq(s2)
11
11
  end
12
12
 
13
- it "correctly patches left-to-right (explicit patch)" do
13
+ it 'correctly patches left-to-right (explicit patch)' do
14
14
  expect(Diff::LCS.patch(s1, patch_set, :patch)).to eq(s2)
15
15
  expect(Diff::LCS.patch!(s1, patch_set)).to eq(s2)
16
16
  end
17
17
 
18
- it "correctly patches right-to-left (unpatch autodiscovery)" do
18
+ it 'correctly patches right-to-left (unpatch autodiscovery)' do
19
19
  expect(Diff::LCS.patch(s2, patch_set)).to eq(s1)
20
20
  end
21
21
 
22
- it "correctly patches right-to-left (explicit unpatch)" do
22
+ it 'correctly patches right-to-left (explicit unpatch)' do
23
23
  expect(Diff::LCS.patch(s2, patch_set, :unpatch)).to eq(s1)
24
24
  expect(Diff::LCS.unpatch!(s2, patch_set)).to eq(s1)
25
25
  end
26
26
  end
27
27
 
28
- describe "using a Diff::LCS.diff patchset" do
29
- describe "an empty patchset returns the source" do
30
- it "works on a string (hello)" do
28
+ describe 'using a Diff::LCS.diff patchset' do
29
+ describe 'an empty patchset returns the source' do
30
+ it 'works on a string (hello)' do
31
31
  diff = Diff::LCS.diff(hello, hello)
32
- expect(Diff::LCS::patch(hello, diff)).to eq(hello)
32
+ expect(Diff::LCS.patch(hello, diff)).to eq(hello)
33
33
  end
34
34
 
35
- it "works on an array %W(h e l l o)" do
35
+ it 'works on an array %W(h e l l o)' do
36
36
  diff = Diff::LCS.diff(hello_ary, hello_ary)
37
- expect(Diff::LCS::patch(hello_ary, diff)).to eq(hello_ary)
37
+ expect(Diff::LCS.patch(hello_ary, diff)).to eq(hello_ary)
38
38
  end
39
39
  end
40
40
 
41
- describe "with default diff callbacks (DiffCallbacks)" do
42
- describe "forward (s1 -> s2)" do
43
- it_has_behavior "patch sequences correctly" do
41
+ describe 'with default diff callbacks (DiffCallbacks)' do
42
+ describe 'forward (s1 -> s2)' do
43
+ it_has_behavior 'patch sequences correctly' do
44
44
  let(:s1) { seq1 }
45
45
  let(:s2) { seq2 }
46
46
  let(:patch_set) { Diff::LCS.diff(seq1, seq2) }
47
47
  end
48
48
  end
49
49
 
50
- describe "reverse (s2 -> s1)" do
51
- it_has_behavior "patch sequences correctly" do
50
+ describe 'reverse (s2 -> s1)' do
51
+ it_has_behavior 'patch sequences correctly' do
52
52
  let(:s1) { seq2 }
53
53
  let(:s2) { seq1 }
54
54
  let(:patch_set) { Diff::LCS.diff(seq2, seq1) }
@@ -56,9 +56,9 @@ describe "Diff::LCS.patch" do
56
56
  end
57
57
  end
58
58
 
59
- describe "with context diff callbacks (ContextDiffCallbacks)" do
60
- describe "forward (s1 -> s2)" do
61
- it_has_behavior "patch sequences correctly" do
59
+ describe 'with context diff callbacks (ContextDiffCallbacks)' do
60
+ describe 'forward (s1 -> s2)' do
61
+ it_has_behavior 'patch sequences correctly' do
62
62
  let(:s1) { seq1 }
63
63
  let(:s2) { seq2 }
64
64
  let(:patch_set) {
@@ -67,8 +67,8 @@ describe "Diff::LCS.patch" do
67
67
  end
68
68
  end
69
69
 
70
- describe "reverse (s2 -> s1)" do
71
- it_has_behavior "patch sequences correctly" do
70
+ describe 'reverse (s2 -> s1)' do
71
+ it_has_behavior 'patch sequences correctly' do
72
72
  let(:s1) { seq2 }
73
73
  let(:s2) { seq1 }
74
74
  let(:patch_set) {
@@ -78,9 +78,9 @@ describe "Diff::LCS.patch" do
78
78
  end
79
79
  end
80
80
 
81
- describe "with sdiff callbacks (SDiffCallbacks)" do
82
- describe "forward (s1 -> s2)" do
83
- it_has_behavior "patch sequences correctly" do
81
+ describe 'with sdiff callbacks (SDiffCallbacks)' do
82
+ describe 'forward (s1 -> s2)' do
83
+ it_has_behavior 'patch sequences correctly' do
84
84
  let(:s1) { seq1 }
85
85
  let(:s2) { seq2 }
86
86
  let(:patch_set) {
@@ -89,8 +89,8 @@ describe "Diff::LCS.patch" do
89
89
  end
90
90
  end
91
91
 
92
- describe "reverse (s2 -> s1)" do
93
- it_has_behavior "patch sequences correctly" do
92
+ describe 'reverse (s2 -> s1)' do
93
+ it_has_behavior 'patch sequences correctly' do
94
94
  let(:s1) { seq2 }
95
95
  let(:s2) { seq1 }
96
96
  let(:patch_set) {
@@ -101,20 +101,20 @@ describe "Diff::LCS.patch" do
101
101
  end
102
102
  end
103
103
 
104
- describe "using a Diff::LCS.sdiff patchset" do
105
- describe "an empty patchset returns the source" do
106
- it "works on a string (hello)" do
107
- expect(Diff::LCS::patch(hello, Diff::LCS.sdiff(hello, hello))).to eq(hello)
104
+ describe 'using a Diff::LCS.sdiff patchset' do
105
+ describe 'an empty patchset returns the source' do
106
+ it 'works on a string (hello)' do
107
+ expect(Diff::LCS.patch(hello, Diff::LCS.sdiff(hello, hello))).to eq(hello)
108
108
  end
109
109
 
110
- it "works on an array %W(h e l l o)" do
111
- expect(Diff::LCS::patch(hello_ary, Diff::LCS.sdiff(hello_ary, hello_ary))).to eq(hello_ary)
110
+ it 'works on an array %W(h e l l o)' do
111
+ expect(Diff::LCS.patch(hello_ary, Diff::LCS.sdiff(hello_ary, hello_ary))).to eq(hello_ary)
112
112
  end
113
113
  end
114
114
 
115
- describe "with default diff callbacks (DiffCallbacks)" do
116
- describe "forward (s1 -> s2)" do
117
- it_has_behavior "patch sequences correctly" do
115
+ describe 'with default diff callbacks (DiffCallbacks)' do
116
+ describe 'forward (s1 -> s2)' do
117
+ it_has_behavior 'patch sequences correctly' do
118
118
  let(:s1) { seq1 }
119
119
  let(:s2) { seq2 }
120
120
  let(:patch_set) {
@@ -123,8 +123,8 @@ describe "Diff::LCS.patch" do
123
123
  end
124
124
  end
125
125
 
126
- describe "reverse (s2 -> s1)" do
127
- it_has_behavior "patch sequences correctly" do
126
+ describe 'reverse (s2 -> s1)' do
127
+ it_has_behavior 'patch sequences correctly' do
128
128
  let(:s1) { seq2 }
129
129
  let(:s2) { seq1 }
130
130
  let(:patch_set) {
@@ -134,9 +134,9 @@ describe "Diff::LCS.patch" do
134
134
  end
135
135
  end
136
136
 
137
- describe "with context diff callbacks (DiffCallbacks)" do
138
- describe "forward (s1 -> s2)" do
139
- it_has_behavior "patch sequences correctly" do
137
+ describe 'with context diff callbacks (DiffCallbacks)' do
138
+ describe 'forward (s1 -> s2)' do
139
+ it_has_behavior 'patch sequences correctly' do
140
140
  let(:s1) { seq1 }
141
141
  let(:s2) { seq2 }
142
142
  let(:patch_set) {
@@ -145,8 +145,8 @@ describe "Diff::LCS.patch" do
145
145
  end
146
146
  end
147
147
 
148
- describe "reverse (s2 -> s1)" do
149
- it_has_behavior "patch sequences correctly" do
148
+ describe 'reverse (s2 -> s1)' do
149
+ it_has_behavior 'patch sequences correctly' do
150
150
  let(:s1) { seq2 }
151
151
  let(:s2) { seq1 }
152
152
  let(:patch_set) {
@@ -156,17 +156,17 @@ describe "Diff::LCS.patch" do
156
156
  end
157
157
  end
158
158
 
159
- describe "with sdiff callbacks (SDiffCallbacks)" do
160
- describe "forward (s1 -> s2)" do
161
- it_has_behavior "patch sequences correctly" do
159
+ describe 'with sdiff callbacks (SDiffCallbacks)' do
160
+ describe 'forward (s1 -> s2)' do
161
+ it_has_behavior 'patch sequences correctly' do
162
162
  let(:s1) { seq1 }
163
163
  let(:s2) { seq2 }
164
164
  let(:patch_set) { Diff::LCS.sdiff(seq1, seq2) }
165
165
  end
166
166
  end
167
167
 
168
- describe "reverse (s2 -> s1)" do
169
- it_has_behavior "patch sequences correctly" do
168
+ describe 'reverse (s2 -> s1)' do
169
+ it_has_behavior 'patch sequences correctly' do
170
170
  let(:s1) { seq2 }
171
171
  let(:s2) { seq1 }
172
172
  let(:patch_set) { Diff::LCS.sdiff(seq2, seq1) }
@@ -179,43 +179,43 @@ describe "Diff::LCS.patch" do
179
179
  # to s2 patches"), this cannot use the "patch sequences correctly" shared
180
180
  # set. Once the bug in autodiscovery is fixed, this can be converted as
181
181
  # above.
182
- describe "fix bug 891: patchsets do not contain the last equal part" do
182
+ describe 'fix bug 891: patchsets do not contain the last equal part' do
183
183
  before :each do
184
- @s1 = %w(a b c d e f g h i j k)
184
+ @s1 = %w(a b c d e f g h i j k) # rubocop:disable Layout/SpaceInsideArrayPercentLiteral
185
185
  @s2 = %w(a b c d D e f g h i j k)
186
186
  end
187
187
 
188
- describe "using Diff::LCS.diff with default diff callbacks" do
188
+ describe 'using Diff::LCS.diff with default diff callbacks' do
189
189
  before :each do
190
190
  @patch_set_s1_s2 = Diff::LCS.diff(@s1, @s2)
191
191
  @patch_set_s2_s1 = Diff::LCS.diff(@s2, @s1)
192
192
  end
193
193
 
194
- it "autodiscovers s1 to s2 patches" do
194
+ it 'autodiscovers s1 to s2 patches' do
195
195
  expect do
196
196
  expect(Diff::LCS.patch(@s1, @patch_set_s1_s2)).to eq(@s2)
197
197
  end.to_not raise_error
198
198
  end
199
199
 
200
- it "autodiscovers s2 to s1 patches" do
200
+ it 'autodiscovers s2 to s1 patches' do
201
201
  expect do
202
202
  expect(Diff::LCS.patch(@s1, @patch_set_s2_s1)).to eq(@s2)
203
203
  end.to_not raise_error
204
204
  end
205
205
 
206
- it "autodiscovers s2 to s1 the left-to-right patches" do
206
+ it 'autodiscovers s2 to s1 the left-to-right patches' do
207
207
  expect(Diff::LCS.patch(@s2, @patch_set_s2_s1)).to eq(@s1)
208
208
  expect(Diff::LCS.patch(@s2, @patch_set_s1_s2)).to eq(@s1)
209
209
  end
210
210
 
211
- it "correctly patches left-to-right (explicit patch)" do
211
+ it 'correctly patches left-to-right (explicit patch)' do
212
212
  expect(Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch)).to eq(@s2)
213
213
  expect(Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch)).to eq(@s1)
214
214
  expect(Diff::LCS.patch!(@s1, @patch_set_s1_s2)).to eq(@s2)
215
215
  expect(Diff::LCS.patch!(@s2, @patch_set_s2_s1)).to eq(@s1)
216
216
  end
217
217
 
218
- it "correctly patches right-to-left (explicit unpatch)" do
218
+ it 'correctly patches right-to-left (explicit unpatch)' do
219
219
  expect(Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch)).to eq(@s1)
220
220
  expect(Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch)).to eq(@s2)
221
221
  expect(Diff::LCS.unpatch!(@s2, @patch_set_s1_s2)).to eq(@s1)
@@ -223,39 +223,37 @@ describe "Diff::LCS.patch" do
223
223
  end
224
224
  end
225
225
 
226
- describe "using Diff::LCS.diff with context diff callbacks" do
226
+ describe 'using Diff::LCS.diff with context diff callbacks' do
227
227
  before :each do
228
- @patch_set_s1_s2 = Diff::LCS.diff(@s1, @s2,
229
- Diff::LCS::ContextDiffCallbacks)
230
- @patch_set_s2_s1 = Diff::LCS.diff(@s2, @s1,
231
- Diff::LCS::ContextDiffCallbacks)
228
+ @patch_set_s1_s2 = Diff::LCS.diff(@s1, @s2, Diff::LCS::ContextDiffCallbacks)
229
+ @patch_set_s2_s1 = Diff::LCS.diff(@s2, @s1, Diff::LCS::ContextDiffCallbacks)
232
230
  end
233
231
 
234
- it "autodiscovers s1 to s2 patches" do
232
+ it 'autodiscovers s1 to s2 patches' do
235
233
  expect do
236
234
  expect(Diff::LCS.patch(@s1, @patch_set_s1_s2)).to eq(@s2)
237
235
  end.to_not raise_error
238
236
  end
239
237
 
240
- it "autodiscovers s2 to s1 patches" do
238
+ it 'autodiscovers s2 to s1 patches' do
241
239
  expect do
242
240
  expect(Diff::LCS.patch(@s1, @patch_set_s2_s1)).to eq(@s2)
243
241
  end.to_not raise_error
244
242
  end
245
243
 
246
- it "autodiscovers s2 to s1 the left-to-right patches" do
244
+ it 'autodiscovers s2 to s1 the left-to-right patches' do
247
245
  expect(Diff::LCS.patch(@s2, @patch_set_s2_s1)).to eq(@s1)
248
246
  expect(Diff::LCS.patch(@s2, @patch_set_s1_s2)).to eq(@s1)
249
247
  end
250
248
 
251
- it "correctly patches left-to-right (explicit patch)" do
249
+ it 'correctly patches left-to-right (explicit patch)' do
252
250
  expect(Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch)).to eq(@s2)
253
251
  expect(Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch)).to eq(@s1)
254
252
  expect(Diff::LCS.patch!(@s1, @patch_set_s1_s2)).to eq(@s2)
255
253
  expect(Diff::LCS.patch!(@s2, @patch_set_s2_s1)).to eq(@s1)
256
254
  end
257
255
 
258
- it "correctly patches right-to-left (explicit unpatch)" do
256
+ it 'correctly patches right-to-left (explicit unpatch)' do
259
257
  expect(Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch)).to eq(@s1)
260
258
  expect(Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch)).to eq(@s2)
261
259
  expect(Diff::LCS.unpatch!(@s2, @patch_set_s1_s2)).to eq(@s1)
@@ -263,39 +261,37 @@ describe "Diff::LCS.patch" do
263
261
  end
264
262
  end
265
263
 
266
- describe "using Diff::LCS.diff with sdiff callbacks" do
264
+ describe 'using Diff::LCS.diff with sdiff callbacks' do
267
265
  before(:each) do
268
- @patch_set_s1_s2 = Diff::LCS.diff(@s1, @s2,
269
- Diff::LCS::SDiffCallbacks)
270
- @patch_set_s2_s1 = Diff::LCS.diff(@s2, @s1,
271
- Diff::LCS::SDiffCallbacks)
266
+ @patch_set_s1_s2 = Diff::LCS.diff(@s1, @s2, Diff::LCS::SDiffCallbacks)
267
+ @patch_set_s2_s1 = Diff::LCS.diff(@s2, @s1, Diff::LCS::SDiffCallbacks)
272
268
  end
273
269
 
274
- it "autodiscovers s1 to s2 patches" do
270
+ it 'autodiscovers s1 to s2 patches' do
275
271
  expect do
276
272
  expect(Diff::LCS.patch(@s1, @patch_set_s1_s2)).to eq(@s2)
277
273
  end.to_not raise_error
278
274
  end
279
275
 
280
- it "autodiscovers s2 to s1 patches" do
276
+ it 'autodiscovers s2 to s1 patches' do
281
277
  expect do
282
278
  expect(Diff::LCS.patch(@s1, @patch_set_s2_s1)).to eq(@s2)
283
279
  end.to_not raise_error
284
280
  end
285
281
 
286
- it "autodiscovers s2 to s1 the left-to-right patches" do
282
+ it 'autodiscovers s2 to s1 the left-to-right patches' do
287
283
  expect(Diff::LCS.patch(@s2, @patch_set_s2_s1)).to eq(@s1)
288
284
  expect(Diff::LCS.patch(@s2, @patch_set_s1_s2)).to eq(@s1)
289
285
  end
290
286
 
291
- it "correctly patches left-to-right (explicit patch)" do
287
+ it 'correctly patches left-to-right (explicit patch)' do
292
288
  expect(Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch)).to eq(@s2)
293
289
  expect(Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch)).to eq(@s1)
294
290
  expect(Diff::LCS.patch!(@s1, @patch_set_s1_s2)).to eq(@s2)
295
291
  expect(Diff::LCS.patch!(@s2, @patch_set_s2_s1)).to eq(@s1)
296
292
  end
297
293
 
298
- it "correctly patches right-to-left (explicit unpatch)" do
294
+ it 'correctly patches right-to-left (explicit unpatch)' do
299
295
  expect(Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch)).to eq(@s1)
300
296
  expect(Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch)).to eq(@s2)
301
297
  expect(Diff::LCS.unpatch!(@s2, @patch_set_s1_s2)).to eq(@s1)
@@ -303,37 +299,37 @@ describe "Diff::LCS.patch" do
303
299
  end
304
300
  end
305
301
 
306
- describe "using Diff::LCS.sdiff with default sdiff callbacks" do
302
+ describe 'using Diff::LCS.sdiff with default sdiff callbacks' do
307
303
  before(:each) do
308
304
  @patch_set_s1_s2 = Diff::LCS.sdiff(@s1, @s2)
309
305
  @patch_set_s2_s1 = Diff::LCS.sdiff(@s2, @s1)
310
306
  end
311
307
 
312
- it "autodiscovers s1 to s2 patches" do
308
+ it 'autodiscovers s1 to s2 patches' do
313
309
  expect do
314
310
  expect(Diff::LCS.patch(@s1, @patch_set_s1_s2)).to eq(@s2)
315
311
  end.to_not raise_error
316
312
  end
317
313
 
318
- it "autodiscovers s2 to s1 patches" do
314
+ it 'autodiscovers s2 to s1 patches' do
319
315
  expect do
320
316
  expect(Diff::LCS.patch(@s1, @patch_set_s2_s1)).to eq(@s2)
321
317
  end.to_not raise_error
322
318
  end
323
319
 
324
- it "autodiscovers s2 to s1 the left-to-right patches" do
320
+ it 'autodiscovers s2 to s1 the left-to-right patches' do
325
321
  expect(Diff::LCS.patch(@s2, @patch_set_s2_s1)).to eq(@s1)
326
322
  expect(Diff::LCS.patch(@s2, @patch_set_s1_s2)).to eq(@s1)
327
323
  end
328
324
 
329
- it "correctly patches left-to-right (explicit patch)" do
325
+ it 'correctly patches left-to-right (explicit patch)' do
330
326
  expect(Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch)).to eq(@s2)
331
327
  expect(Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch)).to eq(@s1)
332
328
  expect(Diff::LCS.patch!(@s1, @patch_set_s1_s2)).to eq(@s2)
333
329
  expect(Diff::LCS.patch!(@s2, @patch_set_s2_s1)).to eq(@s1)
334
330
  end
335
331
 
336
- it "correctly patches right-to-left (explicit unpatch)" do
332
+ it 'correctly patches right-to-left (explicit unpatch)' do
337
333
  expect(Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch)).to eq(@s1)
338
334
  expect(Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch)).to eq(@s2)
339
335
  expect(Diff::LCS.unpatch!(@s2, @patch_set_s1_s2)).to eq(@s1)
@@ -341,39 +337,37 @@ describe "Diff::LCS.patch" do
341
337
  end
342
338
  end
343
339
 
344
- describe "using Diff::LCS.sdiff with context diff callbacks" do
340
+ describe 'using Diff::LCS.sdiff with context diff callbacks' do
345
341
  before(:each) do
346
- @patch_set_s1_s2 = Diff::LCS.sdiff(@s1, @s2,
347
- Diff::LCS::ContextDiffCallbacks)
348
- @patch_set_s2_s1 = Diff::LCS.sdiff(@s2, @s1,
349
- Diff::LCS::ContextDiffCallbacks)
342
+ @patch_set_s1_s2 = Diff::LCS.sdiff(@s1, @s2, Diff::LCS::ContextDiffCallbacks)
343
+ @patch_set_s2_s1 = Diff::LCS.sdiff(@s2, @s1, Diff::LCS::ContextDiffCallbacks)
350
344
  end
351
345
 
352
- it "autodiscovers s1 to s2 patches" do
346
+ it 'autodiscovers s1 to s2 patches' do
353
347
  expect do
354
348
  expect(Diff::LCS.patch(@s1, @patch_set_s1_s2)).to eq(@s2)
355
349
  end.to_not raise_error
356
350
  end
357
351
 
358
- it "autodiscovers s2 to s1 patches" do
352
+ it 'autodiscovers s2 to s1 patches' do
359
353
  expect do
360
354
  expect(Diff::LCS.patch(@s1, @patch_set_s2_s1)).to eq(@s2)
361
355
  end.to_not raise_error
362
356
  end
363
357
 
364
- it "autodiscovers s2 to s1 the left-to-right patches" do
358
+ it 'autodiscovers s2 to s1 the left-to-right patches' do
365
359
  expect(Diff::LCS.patch(@s2, @patch_set_s2_s1)).to eq(@s1)
366
360
  expect(Diff::LCS.patch(@s2, @patch_set_s1_s2)).to eq(@s1)
367
361
  end
368
362
 
369
- it "correctly patches left-to-right (explicit patch)" do
363
+ it 'correctly patches left-to-right (explicit patch)' do
370
364
  expect(Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch)).to eq(@s2)
371
365
  expect(Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch)).to eq(@s1)
372
366
  expect(Diff::LCS.patch!(@s1, @patch_set_s1_s2)).to eq(@s2)
373
367
  expect(Diff::LCS.patch!(@s2, @patch_set_s2_s1)).to eq(@s1)
374
368
  end
375
369
 
376
- it "correctly patches right-to-left (explicit unpatch)" do
370
+ it 'correctly patches right-to-left (explicit unpatch)' do
377
371
  expect(Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch)).to eq(@s1)
378
372
  expect(Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch)).to eq(@s2)
379
373
  expect(Diff::LCS.unpatch!(@s2, @patch_set_s1_s2)).to eq(@s1)
@@ -381,37 +375,37 @@ describe "Diff::LCS.patch" do
381
375
  end
382
376
  end
383
377
 
384
- describe "using Diff::LCS.sdiff with default diff callbacks" do
378
+ describe 'using Diff::LCS.sdiff with default diff callbacks' do
385
379
  before(:each) do
386
380
  @patch_set_s1_s2 = Diff::LCS.sdiff(@s1, @s2, Diff::LCS::DiffCallbacks)
387
381
  @patch_set_s2_s1 = Diff::LCS.sdiff(@s2, @s1, Diff::LCS::DiffCallbacks)
388
382
  end
389
383
 
390
- it "autodiscovers s1 to s2 patches" do
384
+ it 'autodiscovers s1 to s2 patches' do
391
385
  expect do
392
386
  expect(Diff::LCS.patch(@s1, @patch_set_s1_s2)).to eq(@s2)
393
387
  end.to_not raise_error
394
388
  end
395
389
 
396
- it "autodiscovers s2 to s1 patches" do
390
+ it 'autodiscovers s2 to s1 patches' do
397
391
  expect do
398
392
  expect(Diff::LCS.patch(@s1, @patch_set_s2_s1)).to eq(@s2)
399
393
  end.to_not raise_error
400
394
  end
401
395
 
402
- it "autodiscovers s2 to s1 the left-to-right patches" do
396
+ it 'autodiscovers s2 to s1 the left-to-right patches' do
403
397
  expect(Diff::LCS.patch(@s2, @patch_set_s2_s1)).to eq(@s1)
404
398
  expect(Diff::LCS.patch(@s2, @patch_set_s1_s2)).to eq(@s1)
405
399
  end
406
400
 
407
- it "correctly patches left-to-right (explicit patch)" do
401
+ it 'correctly patches left-to-right (explicit patch)' do
408
402
  expect(Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch)).to eq(@s2)
409
403
  expect(Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch)).to eq(@s1)
410
404
  expect(Diff::LCS.patch!(@s1, @patch_set_s1_s2)).to eq(@s2)
411
405
  expect(Diff::LCS.patch!(@s2, @patch_set_s2_s1)).to eq(@s1)
412
406
  end
413
407
 
414
- it "correctly patches right-to-left (explicit unpatch)" do
408
+ it 'correctly patches right-to-left (explicit unpatch)' do
415
409
  expect(Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch)).to eq(@s1)
416
410
  expect(Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch)).to eq(@s2)
417
411
  expect(Diff::LCS.unpatch!(@s2, @patch_set_s1_s2)).to eq(@s1)