diff-lcs 1.2.5 → 1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,50 @@
1
+ 1,3
2
+ 2,7
3
+ 3,13
4
+ 4,21
5
+ 5,31
6
+ 6,43
7
+ 7,57
8
+ 8,73
9
+ 9,91
10
+ 10,111
11
+ 11,133
12
+ 12,157
13
+ 13,183
14
+ 14,211
15
+ 15,241
16
+ 16,273
17
+ 17,307
18
+ 18,343
19
+ 19,381
20
+ 20,421
21
+ 21,463
22
+ 22,507
23
+ 23,553
24
+ 24,601
25
+ 25,651
26
+ 26,703
27
+ 27,757
28
+ 28,813
29
+ 29,871
30
+ 30,931
31
+ 31,993
32
+ 32,1057
33
+ 33,1123
34
+ 34,1191
35
+ 35,1261
36
+ 36,1333
37
+ 37,1407
38
+ 38,1483
39
+ 39,1561
40
+ 40,1641
41
+ 41,1723
42
+ 42,1807
43
+ 43,1893
44
+ 44,1981
45
+ 45,2071
46
+ 46,2163
47
+ 47,2257
48
+ 48,2353
49
+ 49,2451
50
+ 50,2500
@@ -0,0 +1,51 @@
1
+ 1,3
2
+ 2,7
3
+ 3,13
4
+ 4,21
5
+ 5,31
6
+ 6,42
7
+ 7,57
8
+ 8,73
9
+ 9,91
10
+ 10,111
11
+ 11,133
12
+ 12,157
13
+ 13,183
14
+ 14,211
15
+ 15,241
16
+ 16,273
17
+ 17,307
18
+ 18,343
19
+ 19,200
20
+ 20,421
21
+ 21,463
22
+ 22,507
23
+ 23,553
24
+ 24,601
25
+ 25,651
26
+ 26,703
27
+ 27,757
28
+ 28,813
29
+ 29,871
30
+ 30,931
31
+ 31,123
32
+ 32,1057
33
+ 33,1123
34
+ 34,1000
35
+ 35,1261
36
+ 36,1333
37
+ 37,1407
38
+ 38,1483
39
+ 39,1561
40
+ 40,1641
41
+ 41,1723
42
+ 42,1807
43
+ 43,1893
44
+ 44,1981
45
+ 45,2071
46
+ 46,2163
47
+ 47,1524
48
+ 48,2353
49
+ 49,2451
50
+ 50,2500
51
+ 51,2520
@@ -2,28 +2,26 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- def h(v)
6
- v.to_s.bytes.to_a.map { |e| "%02x" % e }.join
7
- end
8
-
9
- describe "Diff::LCS::Hunk" do
10
- if String.method_defined?(:encoding)
5
+ if String.method_defined?(:encoding)
6
+ require 'diff/lcs/hunk'
11
7
 
8
+ describe Diff::LCS::Hunk do
12
9
  let(:old_data) { ["Tu avec carté {count} itém has".encode('UTF-16LE')] }
13
10
  let(:new_data) { ["Tu avec carte {count} item has".encode('UTF-16LE')] }
14
11
  let(:pieces) { Diff::LCS.diff old_data, new_data }
15
12
  let(:hunk) { Diff::LCS::Hunk.new(old_data, new_data, pieces[0], 3, 0) }
16
13
 
17
- it 'should be able to produce a unified diff from the two pieces' do
14
+ it 'produces a unified diff from the two pieces' do
18
15
  expected = (<<-EOD.gsub(/^\s+/,'').encode('UTF-16LE').chomp)
19
16
  @@ -1,2 +1,2 @@
20
17
  -Tu avec carté {count} itém has
21
18
  +Tu avec carte {count} item has
22
19
  EOD
23
- expect(hunk.diff(:unified).to_s == expected).to eql true
20
+
21
+ expect(hunk.diff(:unified)).to eq(expected)
24
22
  end
25
23
 
26
- it 'should be able to produce a context diff from the two pieces' do
24
+ it 'produces a context diff from the two pieces' do
27
25
  expected = (<<-EOD.gsub(/^\s+/,'').encode('UTF-16LE').chomp)
28
26
  ***************
29
27
  *** 1,2 ****
@@ -32,10 +30,10 @@ describe "Diff::LCS::Hunk" do
32
30
  !Tu avec carte {count} item has
33
31
  EOD
34
32
 
35
- expect(hunk.diff(:context).to_s == expected).to eql true
33
+ expect(hunk.diff(:context)).to eq(expected)
36
34
  end
37
35
 
38
- it 'should be able to produce an old diff from the two pieces' do
36
+ it 'produces an old diff from the two pieces' do
39
37
  expected = (<<-EOD.gsub(/^ +/,'').encode('UTF-16LE').chomp)
40
38
  1,2c1,2
41
39
  < Tu avec carté {count} itém has
@@ -43,30 +41,32 @@ describe "Diff::LCS::Hunk" do
43
41
  > Tu avec carte {count} item has
44
42
 
45
43
  EOD
46
- expect(hunk.diff(:old).to_s == expected).to eql true
44
+
45
+ expect(hunk.diff(:old)).to eq(expected)
47
46
  end
48
47
 
49
- it 'should be able to produce a reverse ed diff from the two pieces' do
48
+ it 'produces a reverse ed diff from the two pieces' do
50
49
  expected = (<<-EOD.gsub(/^ +/,'').encode('UTF-16LE').chomp)
51
50
  c1,2
52
51
  Tu avec carte {count} item has
53
52
  .
54
53
 
55
54
  EOD
56
- expect(hunk.diff(:reverse_ed).to_s == expected).to eql true
55
+
56
+ expect(hunk.diff(:reverse_ed)).to eq(expected)
57
57
  end
58
58
 
59
59
  context 'with empty first data set' do
60
60
  let(:old_data) { [] }
61
61
 
62
- it 'should be able to produce a unified diff' do
62
+ it 'produces a unified diff' do
63
63
  expected = (<<-EOD.gsub(/^\s+/,'').encode('UTF-16LE').chomp)
64
64
  @@ -1 +1,2 @@
65
65
  +Tu avec carte {count} item has
66
66
  EOD
67
- expect(hunk.diff(:unified).to_s == expected).to eql true
67
+
68
+ expect(hunk.diff(:unified)).to eq(expected)
68
69
  end
69
70
  end
70
-
71
71
  end
72
72
  end
@@ -5,20 +5,45 @@ require 'spec_helper'
5
5
  describe "Diff::LCS Issues" do
6
6
  include Diff::LCS::SpecHelper::Matchers
7
7
 
8
- it "should not fail to provide a simple patchset (issue 1)" do
9
- s1, s2 = *%W(aX bXaX)
10
- correct_forward_diff = [
11
- [ [ '+', 0, 'b' ],
12
- [ '+', 1, 'X' ] ],
13
- ]
14
-
15
- diff_s1_s2 = Diff::LCS.diff(s1, s2)
16
- change_diff(correct_forward_diff).should == diff_s1_s2
17
- expect do
18
- Diff::LCS.patch(s1, diff_s1_s2).should == s2
19
- end.to_not raise_error(RuntimeError, /provided patchset/)
20
- expect do
21
- Diff::LCS.patch(s2, diff_s1_s2).should == s1
22
- end.to_not raise_error(RuntimeError, /provided patchset/)
8
+ describe 'issue #1' do
9
+ shared_examples 'handles simple diffs' do |s1, s2, forward_diff|
10
+ before do
11
+ @diff_s1_s2 = Diff::LCS.diff(s1, s2)
12
+ end
13
+
14
+ it 'creates the correct diff' do
15
+ expect(change_diff(forward_diff)).to eq(@diff_s1_s2)
16
+ end
17
+
18
+ it 'creates the correct patch s1->s2' do
19
+ expect(Diff::LCS.patch(s1, @diff_s1_s2)).to eq(s2)
20
+ end
21
+
22
+ it 'creates the correct patch s2->s1' do
23
+ expect(Diff::LCS.patch(s2, @diff_s1_s2)).to eq(s1)
24
+ end
25
+ end
26
+
27
+ describe 'string' do
28
+ it_has_behavior 'handles simple diffs', 'aX', 'bXaX', [
29
+ [ [ '+', 0, 'b' ],
30
+ [ '+', 1, 'X' ] ],
31
+ ]
32
+ it_has_behavior 'handles simple diffs', 'bXaX', 'aX', [
33
+ [ [ '-', 0, 'b' ],
34
+ [ '-', 1, 'X' ] ],
35
+ ]
36
+ end
37
+
38
+ describe 'array' do
39
+ it_has_behavior 'handles simple diffs', %w(a X), %w(b X a X), [
40
+ [ [ '+', 0, 'b' ],
41
+ [ '+', 1, 'X' ] ],
42
+ ]
43
+ it_has_behavior 'handles simple diffs', %w(b X a X), %w(a X), [
44
+ [ [ '-', 0, 'b' ],
45
+ [ '-', 1, 'X' ] ],
46
+ ]
47
+ end
23
48
  end
24
49
  end
@@ -2,53 +2,55 @@
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 "should return 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.
12
- res.compact.size.should == correct_lcs.size
13
- res.should correctly_map_sequence(seq1).to_other_sequence(seq2)
12
+ expect(res.compact.size).to eq(correct_lcs.size)
13
+ expect(res).to correctly_map_sequence(seq1).to_other_sequence(seq2)
14
14
 
15
15
  # Compact these transformations and they should be the correct LCS.
16
16
  x_seq1 = (0...res.size).map { |ix| res[ix] ? seq1[ix] : nil }.compact
17
17
  x_seq2 = (0...res.size).map { |ix| res[ix] ? seq2[res[ix]] : nil }.compact
18
18
 
19
- x_seq1.should == correct_lcs
20
- x_seq2.should == correct_lcs
19
+ expect(x_seq1).to eq(correct_lcs)
20
+ expect(x_seq2).to eq(correct_lcs)
21
21
  end
22
22
 
23
- it "should return all indexes with (hello, hello)" do
24
- Diff::LCS::Internals.lcs(hello, hello).should == (0...hello.size).to_a
23
+ it "returns all indexes with (hello, hello)" do
24
+ expect(Diff::LCS::Internals.lcs(hello, hello)).to \
25
+ eq((0...hello.size).to_a)
25
26
  end
26
27
 
27
- it "should return all indexes with (hello_ary, hello_ary)" do
28
- Diff::LCS::Internals.lcs(hello_ary, hello_ary).should == (0...hello_ary.size).to_a
28
+ it "returns all indexes with (hello_ary, hello_ary)" do
29
+ expect(Diff::LCS::Internals.lcs(hello_ary, hello_ary)).to \
30
+ eq((0...hello_ary.size).to_a)
29
31
  end
30
32
  end
31
33
 
32
- describe "Diff::LCS.LCS" do
34
+ describe Diff::LCS, ".LCS" do
33
35
  include Diff::LCS::SpecHelper::Matchers
34
36
 
35
- it "should return the correct compacted values from Diff::LCS.LCS" do
37
+ it "returns the correct compacted values from Diff::LCS.LCS" do
36
38
  res = Diff::LCS.LCS(seq1, seq2)
37
- res.should == correct_lcs
38
- res.compact.should == res
39
+ expect(res).to eq(correct_lcs)
40
+ expect(res.compact).to eq(res)
39
41
  end
40
42
 
41
- it "should be transitive" do
43
+ it "is transitive" do
42
44
  res = Diff::LCS.LCS(seq2, seq1)
43
- res.should == correct_lcs
44
- res.compact.should == res
45
+ expect(res).to eq(correct_lcs)
46
+ expect(res.compact).to eq(res)
45
47
  end
46
48
 
47
- it "should return %W(h e l l o) with (hello, hello)" do
48
- Diff::LCS.LCS(hello, hello).should == 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.split(//))
49
51
  end
50
52
 
51
- it "should return hello_ary with (hello_ary, hello_ary)" do
52
- Diff::LCS.LCS(hello_ary, hello_ary).should == hello_ary
53
+ it "returns hello_ary with (hello_ary, hello_ary)" do
54
+ expect(Diff::LCS.LCS(hello_ary, hello_ary)).to eq(hello_ary)
53
55
  end
54
56
  end
@@ -0,0 +1,47 @@
1
+ # -*- ruby encoding: utf-8 -*-
2
+
3
+ require 'spec_helper'
4
+
5
+ describe "Diff::LCS.diff" do
6
+ include Diff::LCS::SpecHelper::Matchers
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)
11
+ end
12
+
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)
16
+ end
17
+
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
+ ]
26
+
27
+ expect(change_diff(correct_diff)).to eq(diff)
28
+
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)
32
+ end
33
+
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
+ end
39
+
40
+ it "returns an empty diff with (hello, hello)" do
41
+ expect(Diff::LCS.diff(hello, hello)).to eq([])
42
+ end
43
+
44
+ it "returns an empty diff with (hello_ary, hello_ary)" do
45
+ expect(Diff::LCS.diff(hello_ary, hello_ary)).to eq([])
46
+ end
47
+ end
@@ -6,33 +6,35 @@ describe "Diff::LCS.patch" do
6
6
  include Diff::LCS::SpecHelper::Matchers
7
7
 
8
8
  shared_examples "patch sequences correctly" do
9
- it "should correctly patch left-to-right (patch autodiscovery)" do
10
- Diff::LCS.patch(s1, patch_set).should == s2
9
+ it "correctly patches left-to-right (patch autodiscovery)" do
10
+ expect(Diff::LCS.patch(s1, patch_set)).to eq(s2)
11
11
  end
12
12
 
13
- it "should correctly patch left-to-right (explicit patch)" do
14
- Diff::LCS.patch(s1, patch_set, :patch).should == s2
15
- Diff::LCS.patch!(s1, patch_set).should == s2
13
+ it "correctly patches left-to-right (explicit patch)" do
14
+ expect(Diff::LCS.patch(s1, patch_set, :patch)).to eq(s2)
15
+ expect(Diff::LCS.patch!(s1, patch_set)).to eq(s2)
16
16
  end
17
17
 
18
- it "should correctly patch right-to-left (unpatch autodiscovery)" do
19
- Diff::LCS.patch(s2, patch_set).should == s1
18
+ it "correctly patches right-to-left (unpatch autodiscovery)" do
19
+ expect(Diff::LCS.patch(s2, patch_set)).to eq(s1)
20
20
  end
21
21
 
22
- it "should correctly patch right-to-left (explicit unpatch)" do
23
- Diff::LCS.patch(s2, patch_set, :unpatch).should == s1
24
- Diff::LCS.unpatch!(s2, patch_set).should == s1
22
+ it "correctly patches right-to-left (explicit unpatch)" do
23
+ expect(Diff::LCS.patch(s2, patch_set, :unpatch)).to eq(s1)
24
+ expect(Diff::LCS.unpatch!(s2, patch_set)).to eq(s1)
25
25
  end
26
26
  end
27
27
 
28
28
  describe "using a Diff::LCS.diff patchset" do
29
29
  describe "an empty patchset returns the source" do
30
30
  it "works on a string (hello)" do
31
- Diff::LCS::patch(hello, Diff::LCS.diff(hello, hello)).should == hello
31
+ diff = Diff::LCS.diff(hello, hello)
32
+ expect(Diff::LCS::patch(hello, diff)).to eq(hello)
32
33
  end
33
34
 
34
35
  it "works on an array %W(h e l l o)" do
35
- Diff::LCS::patch(hello_ary, Diff::LCS.diff(hello_ary, hello_ary)).should == hello_ary
36
+ diff = Diff::LCS.diff(hello_ary, hello_ary)
37
+ expect(Diff::LCS::patch(hello_ary, diff)).to eq(hello_ary)
36
38
  end
37
39
  end
38
40
 
@@ -102,11 +104,11 @@ describe "Diff::LCS.patch" do
102
104
  describe "using a Diff::LCS.sdiff patchset" do
103
105
  describe "an empty patchset returns the source" do
104
106
  it "works on a string (hello)" do
105
- Diff::LCS::patch(hello, Diff::LCS.sdiff(hello, hello)).should == hello
107
+ expect(Diff::LCS::patch(hello, Diff::LCS.sdiff(hello, hello))).to eq(hello)
106
108
  end
107
109
 
108
110
  it "works on an array %W(h e l l o)" do
109
- Diff::LCS::patch(hello_ary, Diff::LCS.sdiff(hello_ary, hello_ary)).should == hello_ary
111
+ expect(Diff::LCS::patch(hello_ary, Diff::LCS.sdiff(hello_ary, hello_ary))).to eq(hello_ary)
110
112
  end
111
113
  end
112
114
 
@@ -178,122 +180,126 @@ describe "Diff::LCS.patch" do
178
180
  # set. Once the bug in autodiscovery is fixed, this can be converted as
179
181
  # above.
180
182
  describe "fix bug 891: patchsets do not contain the last equal part" do
181
- before(:each) do
183
+ before :each do
182
184
  @s1 = %w(a b c d e f g h i j k)
183
185
  @s2 = %w(a b c d D e f g h i j k)
184
186
  end
185
187
 
186
188
  describe "using Diff::LCS.diff with default diff callbacks" do
187
- before(:each) do
189
+ before :each do
188
190
  @patch_set_s1_s2 = Diff::LCS.diff(@s1, @s2)
189
191
  @patch_set_s2_s1 = Diff::LCS.diff(@s2, @s1)
190
192
  end
191
193
 
192
- it "should autodiscover s1 to s2 patches" do
194
+ it "autodiscovers s1 to s2 patches" do
193
195
  expect do
194
- Diff::LCS.patch(@s1, @patch_set_s1_s2).should == @s2
195
- end.to_not raise_error(RuntimeError, /provided patchset/)
196
+ expect(Diff::LCS.patch(@s1, @patch_set_s1_s2)).to eq(@s2)
197
+ end.to_not raise_error
196
198
  end
197
199
 
198
- it "should autodiscover s2 to s1 patches" do
200
+ it "autodiscovers s2 to s1 patches" do
199
201
  expect do
200
- Diff::LCS.patch(@s1, @patch_set_s2_s1).should == @s2
201
- end.to_not raise_error(RuntimeError, /provided patchset/)
202
+ expect(Diff::LCS.patch(@s1, @patch_set_s2_s1)).to eq(@s2)
203
+ end.to_not raise_error
202
204
  end
203
205
 
204
- it "should autodiscover s2 to s1 the left-to-right patches" do
205
- Diff::LCS.patch(@s2, @patch_set_s2_s1).should == @s1
206
- Diff::LCS.patch(@s2, @patch_set_s1_s2).should == @s1
206
+ it "autodiscovers s2 to s1 the left-to-right patches" do
207
+ expect(Diff::LCS.patch(@s2, @patch_set_s2_s1)).to eq(@s1)
208
+ expect(Diff::LCS.patch(@s2, @patch_set_s1_s2)).to eq(@s1)
207
209
  end
208
210
 
209
- it "should correctly patch left-to-right (explicit patch)" do
210
- Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch).should == @s2
211
- Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch).should == @s1
212
- Diff::LCS.patch!(@s1, @patch_set_s1_s2).should == @s2
213
- Diff::LCS.patch!(@s2, @patch_set_s2_s1).should == @s1
211
+ it "correctly patches left-to-right (explicit patch)" do
212
+ expect(Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch)).to eq(@s2)
213
+ expect(Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch)).to eq(@s1)
214
+ expect(Diff::LCS.patch!(@s1, @patch_set_s1_s2)).to eq(@s2)
215
+ expect(Diff::LCS.patch!(@s2, @patch_set_s2_s1)).to eq(@s1)
214
216
  end
215
217
 
216
- it "should correctly patch right-to-left (explicit unpatch)" do
217
- Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch).should == @s1
218
- Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch).should == @s2
219
- Diff::LCS.unpatch!(@s2, @patch_set_s1_s2).should == @s1
220
- Diff::LCS.unpatch!(@s1, @patch_set_s2_s1).should == @s2
218
+ it "correctly patches right-to-left (explicit unpatch)" do
219
+ expect(Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch)).to eq(@s1)
220
+ expect(Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch)).to eq(@s2)
221
+ expect(Diff::LCS.unpatch!(@s2, @patch_set_s1_s2)).to eq(@s1)
222
+ expect(Diff::LCS.unpatch!(@s1, @patch_set_s2_s1)).to eq(@s2)
221
223
  end
222
224
  end
223
225
 
224
226
  describe "using Diff::LCS.diff with context diff callbacks" do
225
- before(:each) do
226
- @patch_set_s1_s2 = Diff::LCS.diff(@s1, @s2, Diff::LCS::ContextDiffCallbacks)
227
- @patch_set_s2_s1 = Diff::LCS.diff(@s2, @s1, Diff::LCS::ContextDiffCallbacks)
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
232
  end
229
233
 
230
- it "should autodiscover s1 to s2 patches" do
234
+ it "autodiscovers s1 to s2 patches" do
231
235
  expect do
232
- Diff::LCS.patch(@s1, @patch_set_s1_s2).should == @s2
233
- end.to_not raise_error(RuntimeError, /provided patchset/)
236
+ expect(Diff::LCS.patch(@s1, @patch_set_s1_s2)).to eq(@s2)
237
+ end.to_not raise_error
234
238
  end
235
239
 
236
- it "should autodiscover s2 to s1 patches" do
240
+ it "autodiscovers s2 to s1 patches" do
237
241
  expect do
238
- Diff::LCS.patch(@s1, @patch_set_s2_s1).should == @s2
239
- end.to_not raise_error(RuntimeError, /provided patchset/)
242
+ expect(Diff::LCS.patch(@s1, @patch_set_s2_s1)).to eq(@s2)
243
+ end.to_not raise_error
240
244
  end
241
245
 
242
- it "should autodiscover s2 to s1 the left-to-right patches" do
243
- Diff::LCS.patch(@s2, @patch_set_s2_s1).should == @s1
244
- Diff::LCS.patch(@s2, @patch_set_s1_s2).should == @s1
246
+ it "autodiscovers s2 to s1 the left-to-right patches" do
247
+ expect(Diff::LCS.patch(@s2, @patch_set_s2_s1)).to eq(@s1)
248
+ expect(Diff::LCS.patch(@s2, @patch_set_s1_s2)).to eq(@s1)
245
249
  end
246
250
 
247
- it "should correctly patch left-to-right (explicit patch)" do
248
- Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch).should == @s2
249
- Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch).should == @s1
250
- Diff::LCS.patch!(@s1, @patch_set_s1_s2).should == @s2
251
- Diff::LCS.patch!(@s2, @patch_set_s2_s1).should == @s1
251
+ it "correctly patches left-to-right (explicit patch)" do
252
+ expect(Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch)).to eq(@s2)
253
+ expect(Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch)).to eq(@s1)
254
+ expect(Diff::LCS.patch!(@s1, @patch_set_s1_s2)).to eq(@s2)
255
+ expect(Diff::LCS.patch!(@s2, @patch_set_s2_s1)).to eq(@s1)
252
256
  end
253
257
 
254
- it "should correctly patch right-to-left (explicit unpatch)" do
255
- Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch).should == @s1
256
- Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch).should == @s2
257
- Diff::LCS.unpatch!(@s2, @patch_set_s1_s2).should == @s1
258
- Diff::LCS.unpatch!(@s1, @patch_set_s2_s1).should == @s2
258
+ it "correctly patches right-to-left (explicit unpatch)" do
259
+ expect(Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch)).to eq(@s1)
260
+ expect(Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch)).to eq(@s2)
261
+ expect(Diff::LCS.unpatch!(@s2, @patch_set_s1_s2)).to eq(@s1)
262
+ expect(Diff::LCS.unpatch!(@s1, @patch_set_s2_s1)).to eq(@s2)
259
263
  end
260
264
  end
261
265
 
262
266
  describe "using Diff::LCS.diff with sdiff callbacks" do
263
267
  before(:each) do
264
- @patch_set_s1_s2 = Diff::LCS.diff(@s1, @s2, Diff::LCS::SDiffCallbacks)
265
- @patch_set_s2_s1 = Diff::LCS.diff(@s2, @s1, Diff::LCS::SDiffCallbacks)
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
272
  end
267
273
 
268
- it "should autodiscover s1 to s2 patches" do
274
+ it "autodiscovers s1 to s2 patches" do
269
275
  expect do
270
- Diff::LCS.patch(@s1, @patch_set_s1_s2).should == @s2
271
- end.to_not raise_error(RuntimeError, /provided patchset/)
276
+ expect(Diff::LCS.patch(@s1, @patch_set_s1_s2)).to eq(@s2)
277
+ end.to_not raise_error
272
278
  end
273
279
 
274
- it "should autodiscover s2 to s1 patches" do
280
+ it "autodiscovers s2 to s1 patches" do
275
281
  expect do
276
- Diff::LCS.patch(@s1, @patch_set_s2_s1).should == @s2
277
- end.to_not raise_error(RuntimeError, /provided patchset/)
282
+ expect(Diff::LCS.patch(@s1, @patch_set_s2_s1)).to eq(@s2)
283
+ end.to_not raise_error
278
284
  end
279
285
 
280
- it "should autodiscover s2 to s1 the left-to-right patches" do
281
- Diff::LCS.patch(@s2, @patch_set_s2_s1).should == @s1
282
- Diff::LCS.patch(@s2, @patch_set_s1_s2).should == @s1
286
+ it "autodiscovers s2 to s1 the left-to-right patches" do
287
+ expect(Diff::LCS.patch(@s2, @patch_set_s2_s1)).to eq(@s1)
288
+ expect(Diff::LCS.patch(@s2, @patch_set_s1_s2)).to eq(@s1)
283
289
  end
284
290
 
285
- it "should correctly patch left-to-right (explicit patch)" do
286
- Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch).should == @s2
287
- Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch).should == @s1
288
- Diff::LCS.patch!(@s1, @patch_set_s1_s2).should == @s2
289
- Diff::LCS.patch!(@s2, @patch_set_s2_s1).should == @s1
291
+ it "correctly patches left-to-right (explicit patch)" do
292
+ expect(Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch)).to eq(@s2)
293
+ expect(Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch)).to eq(@s1)
294
+ expect(Diff::LCS.patch!(@s1, @patch_set_s1_s2)).to eq(@s2)
295
+ expect(Diff::LCS.patch!(@s2, @patch_set_s2_s1)).to eq(@s1)
290
296
  end
291
297
 
292
- it "should correctly patch right-to-left (explicit unpatch)" do
293
- Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch).should == @s1
294
- Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch).should == @s2
295
- Diff::LCS.unpatch!(@s2, @patch_set_s1_s2).should == @s1
296
- Diff::LCS.unpatch!(@s1, @patch_set_s2_s1).should == @s2
298
+ it "correctly patches right-to-left (explicit unpatch)" do
299
+ expect(Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch)).to eq(@s1)
300
+ expect(Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch)).to eq(@s2)
301
+ expect(Diff::LCS.unpatch!(@s2, @patch_set_s1_s2)).to eq(@s1)
302
+ expect(Diff::LCS.unpatch!(@s1, @patch_set_s2_s1)).to eq(@s2)
297
303
  end
298
304
  end
299
305
 
@@ -303,73 +309,75 @@ describe "Diff::LCS.patch" do
303
309
  @patch_set_s2_s1 = Diff::LCS.sdiff(@s2, @s1)
304
310
  end
305
311
 
306
- it "should autodiscover s1 to s2 patches" do
312
+ it "autodiscovers s1 to s2 patches" do
307
313
  expect do
308
- Diff::LCS.patch(@s1, @patch_set_s1_s2).should == @s2
309
- end.to_not raise_error(RuntimeError, /provided patchset/)
314
+ expect(Diff::LCS.patch(@s1, @patch_set_s1_s2)).to eq(@s2)
315
+ end.to_not raise_error
310
316
  end
311
317
 
312
- it "should autodiscover s2 to s1 patches" do
318
+ it "autodiscovers s2 to s1 patches" do
313
319
  expect do
314
- Diff::LCS.patch(@s1, @patch_set_s2_s1).should == @s2
315
- end.to_not raise_error(RuntimeError, /provided patchset/)
320
+ expect(Diff::LCS.patch(@s1, @patch_set_s2_s1)).to eq(@s2)
321
+ end.to_not raise_error
316
322
  end
317
323
 
318
- it "should autodiscover s2 to s1 the left-to-right patches" do
319
- Diff::LCS.patch(@s2, @patch_set_s2_s1).should == @s1
320
- Diff::LCS.patch(@s2, @patch_set_s1_s2).should == @s1
324
+ it "autodiscovers s2 to s1 the left-to-right patches" do
325
+ expect(Diff::LCS.patch(@s2, @patch_set_s2_s1)).to eq(@s1)
326
+ expect(Diff::LCS.patch(@s2, @patch_set_s1_s2)).to eq(@s1)
321
327
  end
322
328
 
323
- it "should correctly patch left-to-right (explicit patch)", :only => true do
324
- Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch).should == @s2
325
- Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch).should == @s1
326
- Diff::LCS.patch!(@s1, @patch_set_s1_s2).should == @s2
327
- Diff::LCS.patch!(@s2, @patch_set_s2_s1).should == @s1
329
+ it "correctly patches left-to-right (explicit patch)" do
330
+ expect(Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch)).to eq(@s2)
331
+ expect(Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch)).to eq(@s1)
332
+ expect(Diff::LCS.patch!(@s1, @patch_set_s1_s2)).to eq(@s2)
333
+ expect(Diff::LCS.patch!(@s2, @patch_set_s2_s1)).to eq(@s1)
328
334
  end
329
335
 
330
- it "should correctly patch right-to-left (explicit unpatch)" do
331
- Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch).should == @s1
332
- Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch).should == @s2
333
- Diff::LCS.unpatch!(@s2, @patch_set_s1_s2).should == @s1
334
- Diff::LCS.unpatch!(@s1, @patch_set_s2_s1).should == @s2
336
+ it "correctly patches right-to-left (explicit unpatch)" do
337
+ expect(Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch)).to eq(@s1)
338
+ expect(Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch)).to eq(@s2)
339
+ expect(Diff::LCS.unpatch!(@s2, @patch_set_s1_s2)).to eq(@s1)
340
+ expect(Diff::LCS.unpatch!(@s1, @patch_set_s2_s1)).to eq(@s2)
335
341
  end
336
342
  end
337
343
 
338
344
  describe "using Diff::LCS.sdiff with context diff callbacks" do
339
345
  before(:each) do
340
- @patch_set_s1_s2 = Diff::LCS.sdiff(@s1, @s2, Diff::LCS::ContextDiffCallbacks)
341
- @patch_set_s2_s1 = Diff::LCS.sdiff(@s2, @s1, Diff::LCS::ContextDiffCallbacks)
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
350
  end
343
351
 
344
- it "should autodiscover s1 to s2 patches" do
352
+ it "autodiscovers s1 to s2 patches" do
345
353
  expect do
346
- Diff::LCS.patch(@s1, @patch_set_s1_s2).should == @s2
347
- end.to_not raise_error(RuntimeError, /provided patchset/)
354
+ expect(Diff::LCS.patch(@s1, @patch_set_s1_s2)).to eq(@s2)
355
+ end.to_not raise_error
348
356
  end
349
357
 
350
- it "should autodiscover s2 to s1 patches" do
358
+ it "autodiscovers s2 to s1 patches" do
351
359
  expect do
352
- Diff::LCS.patch(@s1, @patch_set_s2_s1).should == @s2
353
- end.to_not raise_error(RuntimeError, /provided patchset/)
360
+ expect(Diff::LCS.patch(@s1, @patch_set_s2_s1)).to eq(@s2)
361
+ end.to_not raise_error
354
362
  end
355
363
 
356
- it "should autodiscover s2 to s1 the left-to-right patches" do
357
- Diff::LCS.patch(@s2, @patch_set_s2_s1).should == @s1
358
- Diff::LCS.patch(@s2, @patch_set_s1_s2).should == @s1
364
+ it "autodiscovers s2 to s1 the left-to-right patches" do
365
+ expect(Diff::LCS.patch(@s2, @patch_set_s2_s1)).to eq(@s1)
366
+ expect(Diff::LCS.patch(@s2, @patch_set_s1_s2)).to eq(@s1)
359
367
  end
360
368
 
361
- it "should correctly patch left-to-right (explicit patch)" do
362
- Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch).should == @s2
363
- Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch).should == @s1
364
- Diff::LCS.patch!(@s1, @patch_set_s1_s2).should == @s2
365
- Diff::LCS.patch!(@s2, @patch_set_s2_s1).should == @s1
369
+ it "correctly patches left-to-right (explicit patch)" do
370
+ expect(Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch)).to eq(@s2)
371
+ expect(Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch)).to eq(@s1)
372
+ expect(Diff::LCS.patch!(@s1, @patch_set_s1_s2)).to eq(@s2)
373
+ expect(Diff::LCS.patch!(@s2, @patch_set_s2_s1)).to eq(@s1)
366
374
  end
367
375
 
368
- it "should correctly patch right-to-left (explicit unpatch)" do
369
- Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch).should == @s1
370
- Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch).should == @s2
371
- Diff::LCS.unpatch!(@s2, @patch_set_s1_s2).should == @s1
372
- Diff::LCS.unpatch!(@s1, @patch_set_s2_s1).should == @s2
376
+ it "correctly patches right-to-left (explicit unpatch)" do
377
+ expect(Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch)).to eq(@s1)
378
+ expect(Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch)).to eq(@s2)
379
+ expect(Diff::LCS.unpatch!(@s2, @patch_set_s1_s2)).to eq(@s1)
380
+ expect(Diff::LCS.unpatch!(@s1, @patch_set_s2_s1)).to eq(@s2)
373
381
  end
374
382
  end
375
383
 
@@ -379,35 +387,35 @@ describe "Diff::LCS.patch" do
379
387
  @patch_set_s2_s1 = Diff::LCS.sdiff(@s2, @s1, Diff::LCS::DiffCallbacks)
380
388
  end
381
389
 
382
- it "should autodiscover s1 to s2 patches" do
390
+ it "autodiscovers s1 to s2 patches" do
383
391
  expect do
384
- Diff::LCS.patch(@s1, @patch_set_s1_s2).should == @s2
385
- end.to_not raise_error(RuntimeError, /provided patchset/)
392
+ expect(Diff::LCS.patch(@s1, @patch_set_s1_s2)).to eq(@s2)
393
+ end.to_not raise_error
386
394
  end
387
395
 
388
- it "should autodiscover s2 to s1 patches" do
396
+ it "autodiscovers s2 to s1 patches" do
389
397
  expect do
390
- Diff::LCS.patch(@s1, @patch_set_s2_s1).should == @s2
391
- end.to_not raise_error(RuntimeError, /provided patchset/)
398
+ expect(Diff::LCS.patch(@s1, @patch_set_s2_s1)).to eq(@s2)
399
+ end.to_not raise_error
392
400
  end
393
401
 
394
- it "should autodiscover s2 to s1 the left-to-right patches" do
395
- Diff::LCS.patch(@s2, @patch_set_s2_s1).should == @s1
396
- Diff::LCS.patch(@s2, @patch_set_s1_s2).should == @s1
402
+ it "autodiscovers s2 to s1 the left-to-right patches" do
403
+ expect(Diff::LCS.patch(@s2, @patch_set_s2_s1)).to eq(@s1)
404
+ expect(Diff::LCS.patch(@s2, @patch_set_s1_s2)).to eq(@s1)
397
405
  end
398
406
 
399
- it "should correctly patch left-to-right (explicit patch)" do
400
- Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch).should == @s2
401
- Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch).should == @s1
402
- Diff::LCS.patch!(@s1, @patch_set_s1_s2).should == @s2
403
- Diff::LCS.patch!(@s2, @patch_set_s2_s1).should == @s1
407
+ it "correctly patches left-to-right (explicit patch)" do
408
+ expect(Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch)).to eq(@s2)
409
+ expect(Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch)).to eq(@s1)
410
+ expect(Diff::LCS.patch!(@s1, @patch_set_s1_s2)).to eq(@s2)
411
+ expect(Diff::LCS.patch!(@s2, @patch_set_s2_s1)).to eq(@s1)
404
412
  end
405
413
 
406
- it "should correctly patch right-to-left (explicit unpatch)" do
407
- Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch).should == @s1
408
- Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch).should == @s2
409
- Diff::LCS.unpatch!(@s2, @patch_set_s1_s2).should == @s1
410
- Diff::LCS.unpatch!(@s1, @patch_set_s2_s1).should == @s2
414
+ it "correctly patches right-to-left (explicit unpatch)" do
415
+ expect(Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch)).to eq(@s1)
416
+ expect(Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch)).to eq(@s2)
417
+ expect(Diff::LCS.unpatch!(@s2, @patch_set_s1_s2)).to eq(@s1)
418
+ expect(Diff::LCS.unpatch!(@s1, @patch_set_s2_s1)).to eq(@s2)
411
419
  end
412
420
  end
413
421
  end