diff-lcs 1.1.3 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec +1 -0
  3. data/Code-of-Conduct.md +74 -0
  4. data/Contributing.md +119 -0
  5. data/History.md +400 -0
  6. data/{License.rdoc → License.md} +6 -5
  7. data/Manifest.txt +36 -4
  8. data/README.rdoc +35 -23
  9. data/Rakefile +106 -11
  10. data/bin/htmldiff +7 -4
  11. data/bin/ldiff +4 -1
  12. data/docs/COPYING.txt +21 -22
  13. data/docs/artistic.txt +127 -0
  14. data/lib/diff/lcs/array.rb +1 -15
  15. data/lib/diff/lcs/backports.rb +9 -0
  16. data/lib/diff/lcs/block.rb +4 -18
  17. data/lib/diff/lcs/callbacks.rb +233 -230
  18. data/lib/diff/lcs/change.rb +114 -109
  19. data/lib/diff/lcs/htmldiff.rb +17 -18
  20. data/lib/diff/lcs/hunk.rb +232 -116
  21. data/lib/diff/lcs/internals.rb +308 -0
  22. data/lib/diff/lcs/ldiff.rb +138 -177
  23. data/lib/diff/lcs/string.rb +1 -15
  24. data/lib/diff/lcs.rb +597 -963
  25. data/lib/diff-lcs.rb +1 -3
  26. data/spec/change_spec.rb +89 -0
  27. data/spec/diff_spec.rb +32 -16
  28. data/spec/fixtures/aX +1 -0
  29. data/spec/fixtures/bXaX +1 -0
  30. data/spec/fixtures/ds1.csv +50 -0
  31. data/spec/fixtures/ds2.csv +51 -0
  32. data/spec/fixtures/ldiff/output.diff +4 -0
  33. data/spec/fixtures/ldiff/output.diff-c +7 -0
  34. data/spec/fixtures/ldiff/output.diff-e +3 -0
  35. data/spec/fixtures/ldiff/output.diff-f +3 -0
  36. data/spec/fixtures/ldiff/output.diff-u +5 -0
  37. data/spec/fixtures/ldiff/output.diff.chef +4 -0
  38. data/spec/fixtures/ldiff/output.diff.chef-c +15 -0
  39. data/spec/fixtures/ldiff/output.diff.chef-e +3 -0
  40. data/spec/fixtures/ldiff/output.diff.chef-f +3 -0
  41. data/spec/fixtures/ldiff/output.diff.chef-u +9 -0
  42. data/spec/fixtures/ldiff/output.diff.chef2 +7 -0
  43. data/spec/fixtures/ldiff/output.diff.chef2-c +20 -0
  44. data/spec/fixtures/ldiff/output.diff.chef2-d +7 -0
  45. data/spec/fixtures/ldiff/output.diff.chef2-e +7 -0
  46. data/spec/fixtures/ldiff/output.diff.chef2-f +7 -0
  47. data/spec/fixtures/ldiff/output.diff.chef2-u +16 -0
  48. data/spec/fixtures/new-chef +4 -0
  49. data/spec/fixtures/new-chef2 +17 -0
  50. data/spec/fixtures/old-chef +4 -0
  51. data/spec/fixtures/old-chef2 +14 -0
  52. data/spec/hunk_spec.rb +83 -0
  53. data/spec/issues_spec.rb +154 -0
  54. data/spec/lcs_spec.rb +36 -16
  55. data/spec/ldiff_spec.rb +87 -0
  56. data/spec/patch_spec.rb +198 -172
  57. data/spec/sdiff_spec.rb +99 -89
  58. data/spec/spec_helper.rb +149 -59
  59. data/spec/traverse_balanced_spec.rb +191 -167
  60. data/spec/traverse_sequences_spec.rb +105 -51
  61. metadata +218 -99
  62. data/.gemtest +0 -0
  63. data/History.rdoc +0 -54
  64. data/diff-lcs.gemspec +0 -51
  65. data/docs/artistic.html +0 -289
data/spec/patch_spec.rb CHANGED
@@ -1,42 +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 "should correctly patch left-to-right (patch autodiscovery)" do
10
- Diff::LCS.patch(s1, patch_set).should == s2
8
+ shared_examples 'patch sequences correctly' do
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
- describe "using a Diff::LCS.diff patchset" do
29
- describe "with default diff callbacks (DiffCallbacks)" do
30
- describe "forward (s1 -> s2)" do
31
- it_has_behavior "patch sequences correctly" 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
+ diff = Diff::LCS.diff(hello, hello)
32
+ expect(Diff::LCS.patch(hello, diff)).to eq(hello)
33
+ end
34
+
35
+ it 'works on an array %W(h e l l o)' do
36
+ diff = Diff::LCS.diff(hello_ary, hello_ary)
37
+ expect(Diff::LCS.patch(hello_ary, diff)).to eq(hello_ary)
38
+ end
39
+ end
40
+
41
+ describe 'with default diff callbacks (DiffCallbacks)' do
42
+ describe 'forward (s1 -> s2)' do
43
+ it_has_behavior 'patch sequences correctly' do
32
44
  let(:s1) { seq1 }
33
45
  let(:s2) { seq2 }
34
46
  let(:patch_set) { Diff::LCS.diff(seq1, seq2) }
35
47
  end
36
48
  end
37
49
 
38
- describe "reverse (s2 -> s1)" do
39
- it_has_behavior "patch sequences correctly" do
50
+ describe 'reverse (s2 -> s1)' do
51
+ it_has_behavior 'patch sequences correctly' do
40
52
  let(:s1) { seq2 }
41
53
  let(:s2) { seq1 }
42
54
  let(:patch_set) { Diff::LCS.diff(seq2, seq1) }
@@ -44,9 +56,9 @@ describe "Diff::LCS.patch" do
44
56
  end
45
57
  end
46
58
 
47
- describe "with context diff callbacks (ContextDiffCallbacks)" do
48
- describe "forward (s1 -> s2)" do
49
- 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
50
62
  let(:s1) { seq1 }
51
63
  let(:s2) { seq2 }
52
64
  let(:patch_set) {
@@ -55,8 +67,8 @@ describe "Diff::LCS.patch" do
55
67
  end
56
68
  end
57
69
 
58
- describe "reverse (s2 -> s1)" do
59
- it_has_behavior "patch sequences correctly" do
70
+ describe 'reverse (s2 -> s1)' do
71
+ it_has_behavior 'patch sequences correctly' do
60
72
  let(:s1) { seq2 }
61
73
  let(:s2) { seq1 }
62
74
  let(:patch_set) {
@@ -66,9 +78,9 @@ describe "Diff::LCS.patch" do
66
78
  end
67
79
  end
68
80
 
69
- describe "with sdiff callbacks (SDiffCallbacks)" do
70
- describe "forward (s1 -> s2)" do
71
- 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
72
84
  let(:s1) { seq1 }
73
85
  let(:s2) { seq2 }
74
86
  let(:patch_set) {
@@ -77,8 +89,8 @@ describe "Diff::LCS.patch" do
77
89
  end
78
90
  end
79
91
 
80
- describe "reverse (s2 -> s1)" do
81
- it_has_behavior "patch sequences correctly" do
92
+ describe 'reverse (s2 -> s1)' do
93
+ it_has_behavior 'patch sequences correctly' do
82
94
  let(:s1) { seq2 }
83
95
  let(:s2) { seq1 }
84
96
  let(:patch_set) {
@@ -89,10 +101,20 @@ describe "Diff::LCS.patch" do
89
101
  end
90
102
  end
91
103
 
92
- describe "using a Diff::LCS.sdiff patchset" do
93
- describe "with default diff callbacks (DiffCallbacks)" do
94
- describe "forward (s1 -> s2)" do
95
- it_has_behavior "patch sequences correctly" do
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
+ end
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)
112
+ end
113
+ end
114
+
115
+ describe 'with default diff callbacks (DiffCallbacks)' do
116
+ describe 'forward (s1 -> s2)' do
117
+ it_has_behavior 'patch sequences correctly' do
96
118
  let(:s1) { seq1 }
97
119
  let(:s2) { seq2 }
98
120
  let(:patch_set) {
@@ -101,8 +123,8 @@ describe "Diff::LCS.patch" do
101
123
  end
102
124
  end
103
125
 
104
- describe "reverse (s2 -> s1)" do
105
- it_has_behavior "patch sequences correctly" do
126
+ describe 'reverse (s2 -> s1)' do
127
+ it_has_behavior 'patch sequences correctly' do
106
128
  let(:s1) { seq2 }
107
129
  let(:s2) { seq1 }
108
130
  let(:patch_set) {
@@ -112,9 +134,9 @@ describe "Diff::LCS.patch" do
112
134
  end
113
135
  end
114
136
 
115
- describe "with context diff callbacks (DiffCallbacks)" do
116
- describe "forward (s1 -> s2)" do
117
- 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
118
140
  let(:s1) { seq1 }
119
141
  let(:s2) { seq2 }
120
142
  let(:patch_set) {
@@ -123,8 +145,8 @@ describe "Diff::LCS.patch" do
123
145
  end
124
146
  end
125
147
 
126
- describe "reverse (s2 -> s1)" do
127
- it_has_behavior "patch sequences correctly" do
148
+ describe 'reverse (s2 -> s1)' do
149
+ it_has_behavior 'patch sequences correctly' do
128
150
  let(:s1) { seq2 }
129
151
  let(:s2) { seq1 }
130
152
  let(:patch_set) {
@@ -134,17 +156,17 @@ describe "Diff::LCS.patch" do
134
156
  end
135
157
  end
136
158
 
137
- describe "with sdiff callbacks (SDiffCallbacks)" do
138
- describe "forward (s1 -> s2)" do
139
- 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
140
162
  let(:s1) { seq1 }
141
163
  let(:s2) { seq2 }
142
164
  let(:patch_set) { Diff::LCS.sdiff(seq1, seq2) }
143
165
  end
144
166
  end
145
167
 
146
- describe "reverse (s2 -> s1)" do
147
- it_has_behavior "patch sequences correctly" do
168
+ describe 'reverse (s2 -> s1)' do
169
+ it_has_behavior 'patch sequences correctly' do
148
170
  let(:s1) { seq2 }
149
171
  let(:s2) { seq1 }
150
172
  let(:patch_set) { Diff::LCS.sdiff(seq2, seq1) }
@@ -157,234 +179,238 @@ describe "Diff::LCS.patch" do
157
179
  # to s2 patches"), this cannot use the "patch sequences correctly" shared
158
180
  # set. Once the bug in autodiscovery is fixed, this can be converted as
159
181
  # above.
160
- describe "fix bug 891: patchsets do not contain the last equal part" do
161
- before(:each) do
162
- @s1 = %w(a b c d e f g h i j k)
182
+ describe 'fix bug 891: patchsets do not contain the last equal part' do
183
+ before :each do
184
+ @s1 = %w(a b c d e f g h i j k) # rubocop:disable Layout/SpaceInsideArrayPercentLiteral
163
185
  @s2 = %w(a b c d D e f g h i j k)
164
186
  end
165
187
 
166
- describe "using Diff::LCS.diff with default diff callbacks" do
167
- before(:each) do
188
+ describe 'using Diff::LCS.diff with default diff callbacks' do
189
+ before :each do
168
190
  @patch_set_s1_s2 = Diff::LCS.diff(@s1, @s2)
169
191
  @patch_set_s2_s1 = Diff::LCS.diff(@s2, @s1)
170
192
  end
171
193
 
172
- it "does not autodiscover s1 to s2 patches" do
173
- # It should, but it doesn't.
194
+ it 'autodiscovers s1 to s2 patches' do
174
195
  expect do
175
- Diff::LCS.patch(@s1, @patch_set_s1_s2).should == @s2
176
- end.to raise_error(RuntimeError, /provided patchset/)
196
+ expect(Diff::LCS.patch(@s1, @patch_set_s1_s2)).to eq(@s2)
197
+ end.to_not raise_error
198
+ end
177
199
 
200
+ it 'autodiscovers s2 to s1 patches' do
178
201
  expect do
179
- Diff::LCS.patch(@s1, @patch_set_s2_s1).should == @s2
180
- end.to raise_error(RuntimeError, /provided patchset/)
202
+ expect(Diff::LCS.patch(@s1, @patch_set_s2_s1)).to eq(@s2)
203
+ end.to_not raise_error
181
204
  end
182
205
 
183
- it "should autodiscover s2 to s1 the left-to-right patches" do
184
- Diff::LCS.patch(@s2, @patch_set_s2_s1).should == @s1
185
- 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)
186
209
  end
187
210
 
188
- it "should correctly patch left-to-right (explicit patch)" do
189
- Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch).should == @s2
190
- Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch).should == @s1
191
- Diff::LCS.patch!(@s1, @patch_set_s1_s2).should == @s2
192
- 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)
193
216
  end
194
217
 
195
- it "should correctly patch right-to-left (explicit unpatch)" do
196
- Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch).should == @s1
197
- Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch).should == @s2
198
- Diff::LCS.unpatch!(@s2, @patch_set_s1_s2).should == @s1
199
- 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)
200
223
  end
201
224
  end
202
225
 
203
- describe "using Diff::LCS.diff with context diff callbacks" do
204
- before(:each) do
226
+ describe 'using Diff::LCS.diff with context diff callbacks' do
227
+ before :each do
205
228
  @patch_set_s1_s2 = Diff::LCS.diff(@s1, @s2, Diff::LCS::ContextDiffCallbacks)
206
229
  @patch_set_s2_s1 = Diff::LCS.diff(@s2, @s1, Diff::LCS::ContextDiffCallbacks)
207
230
  end
208
231
 
209
- it "does not autodiscover s1 to s2 patches" do
210
- # It should, but it doesn't.
232
+ it 'autodiscovers s1 to s2 patches' do
211
233
  expect do
212
- Diff::LCS.patch(@s1, @patch_set_s1_s2).should == @s2
213
- end.to raise_error(RuntimeError, /provided patchset/)
234
+ expect(Diff::LCS.patch(@s1, @patch_set_s1_s2)).to eq(@s2)
235
+ end.to_not raise_error
236
+ end
214
237
 
238
+ it 'autodiscovers s2 to s1 patches' do
215
239
  expect do
216
- Diff::LCS.patch(@s1, @patch_set_s2_s1).should == @s2
217
- end.to raise_error(RuntimeError, /provided patchset/)
240
+ expect(Diff::LCS.patch(@s1, @patch_set_s2_s1)).to eq(@s2)
241
+ end.to_not raise_error
218
242
  end
219
243
 
220
- it "should autodiscover s2 to s1 the left-to-right patches" do
221
- Diff::LCS.patch(@s2, @patch_set_s2_s1).should == @s1
222
- Diff::LCS.patch(@s2, @patch_set_s1_s2).should == @s1
244
+ it 'autodiscovers s2 to s1 the left-to-right patches' do
245
+ expect(Diff::LCS.patch(@s2, @patch_set_s2_s1)).to eq(@s1)
246
+ expect(Diff::LCS.patch(@s2, @patch_set_s1_s2)).to eq(@s1)
223
247
  end
224
248
 
225
- it "should correctly patch left-to-right (explicit patch)" do
226
- Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch).should == @s2
227
- Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch).should == @s1
228
- Diff::LCS.patch!(@s1, @patch_set_s1_s2).should == @s2
229
- Diff::LCS.patch!(@s2, @patch_set_s2_s1).should == @s1
249
+ it 'correctly patches left-to-right (explicit patch)' do
250
+ expect(Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch)).to eq(@s2)
251
+ expect(Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch)).to eq(@s1)
252
+ expect(Diff::LCS.patch!(@s1, @patch_set_s1_s2)).to eq(@s2)
253
+ expect(Diff::LCS.patch!(@s2, @patch_set_s2_s1)).to eq(@s1)
230
254
  end
231
255
 
232
- it "should correctly patch right-to-left (explicit unpatch)" do
233
- Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch).should == @s1
234
- Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch).should == @s2
235
- Diff::LCS.unpatch!(@s2, @patch_set_s1_s2).should == @s1
236
- Diff::LCS.unpatch!(@s1, @patch_set_s2_s1).should == @s2
256
+ it 'correctly patches right-to-left (explicit unpatch)' do
257
+ expect(Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch)).to eq(@s1)
258
+ expect(Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch)).to eq(@s2)
259
+ expect(Diff::LCS.unpatch!(@s2, @patch_set_s1_s2)).to eq(@s1)
260
+ expect(Diff::LCS.unpatch!(@s1, @patch_set_s2_s1)).to eq(@s2)
237
261
  end
238
262
  end
239
263
 
240
- describe "using Diff::LCS.diff with sdiff callbacks" do
264
+ describe 'using Diff::LCS.diff with sdiff callbacks' do
241
265
  before(:each) do
242
266
  @patch_set_s1_s2 = Diff::LCS.diff(@s1, @s2, Diff::LCS::SDiffCallbacks)
243
267
  @patch_set_s2_s1 = Diff::LCS.diff(@s2, @s1, Diff::LCS::SDiffCallbacks)
244
268
  end
245
269
 
246
- it "does not autodiscover s1 to s2 patches" do
247
- # It should, but it doesn't.
270
+ it 'autodiscovers s1 to s2 patches' do
248
271
  expect do
249
- Diff::LCS.patch(@s1, @patch_set_s1_s2).should == @s2
250
- end.to raise_error(RuntimeError, /provided patchset/)
272
+ expect(Diff::LCS.patch(@s1, @patch_set_s1_s2)).to eq(@s2)
273
+ end.to_not raise_error
274
+ end
251
275
 
276
+ it 'autodiscovers s2 to s1 patches' do
252
277
  expect do
253
- Diff::LCS.patch(@s1, @patch_set_s2_s1).should == @s2
254
- end.to raise_error(RuntimeError, /provided patchset/)
278
+ expect(Diff::LCS.patch(@s1, @patch_set_s2_s1)).to eq(@s2)
279
+ end.to_not raise_error
255
280
  end
256
281
 
257
- it "should autodiscover s2 to s1 the left-to-right patches" do
258
- Diff::LCS.patch(@s2, @patch_set_s2_s1).should == @s1
259
- Diff::LCS.patch(@s2, @patch_set_s1_s2).should == @s1
282
+ it 'autodiscovers s2 to s1 the left-to-right patches' do
283
+ expect(Diff::LCS.patch(@s2, @patch_set_s2_s1)).to eq(@s1)
284
+ expect(Diff::LCS.patch(@s2, @patch_set_s1_s2)).to eq(@s1)
260
285
  end
261
286
 
262
- it "should correctly patch left-to-right (explicit patch)" do
263
- Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch).should == @s2
264
- Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch).should == @s1
265
- Diff::LCS.patch!(@s1, @patch_set_s1_s2).should == @s2
266
- Diff::LCS.patch!(@s2, @patch_set_s2_s1).should == @s1
287
+ it 'correctly patches left-to-right (explicit patch)' do
288
+ expect(Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch)).to eq(@s2)
289
+ expect(Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch)).to eq(@s1)
290
+ expect(Diff::LCS.patch!(@s1, @patch_set_s1_s2)).to eq(@s2)
291
+ expect(Diff::LCS.patch!(@s2, @patch_set_s2_s1)).to eq(@s1)
267
292
  end
268
293
 
269
- it "should correctly patch right-to-left (explicit unpatch)" do
270
- Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch).should == @s1
271
- Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch).should == @s2
272
- Diff::LCS.unpatch!(@s2, @patch_set_s1_s2).should == @s1
273
- Diff::LCS.unpatch!(@s1, @patch_set_s2_s1).should == @s2
294
+ it 'correctly patches right-to-left (explicit unpatch)' do
295
+ expect(Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch)).to eq(@s1)
296
+ expect(Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch)).to eq(@s2)
297
+ expect(Diff::LCS.unpatch!(@s2, @patch_set_s1_s2)).to eq(@s1)
298
+ expect(Diff::LCS.unpatch!(@s1, @patch_set_s2_s1)).to eq(@s2)
274
299
  end
275
300
  end
276
301
 
277
- describe "using Diff::LCS.sdiff with default sdiff callbacks" do
302
+ describe 'using Diff::LCS.sdiff with default sdiff callbacks' do
278
303
  before(:each) do
279
304
  @patch_set_s1_s2 = Diff::LCS.sdiff(@s1, @s2)
280
305
  @patch_set_s2_s1 = Diff::LCS.sdiff(@s2, @s1)
281
306
  end
282
307
 
283
- it "does not autodiscover s1 to s2 patches" do
284
- # It should, but it doesn't.
308
+ it 'autodiscovers s1 to s2 patches' do
285
309
  expect do
286
- Diff::LCS.patch(@s1, @patch_set_s1_s2).should == @s2
287
- end.to raise_error(RuntimeError, /provided patchset/)
310
+ expect(Diff::LCS.patch(@s1, @patch_set_s1_s2)).to eq(@s2)
311
+ end.to_not raise_error
312
+ end
288
313
 
314
+ it 'autodiscovers s2 to s1 patches' do
289
315
  expect do
290
- Diff::LCS.patch(@s1, @patch_set_s2_s1).should == @s2
291
- end.to raise_error(RuntimeError, /provided patchset/)
316
+ expect(Diff::LCS.patch(@s1, @patch_set_s2_s1)).to eq(@s2)
317
+ end.to_not raise_error
292
318
  end
293
319
 
294
- it "should autodiscover s2 to s1 the left-to-right patches" do
295
- Diff::LCS.patch(@s2, @patch_set_s2_s1).should == @s1
296
- Diff::LCS.patch(@s2, @patch_set_s1_s2).should == @s1
320
+ it 'autodiscovers s2 to s1 the left-to-right patches' do
321
+ expect(Diff::LCS.patch(@s2, @patch_set_s2_s1)).to eq(@s1)
322
+ expect(Diff::LCS.patch(@s2, @patch_set_s1_s2)).to eq(@s1)
297
323
  end
298
324
 
299
- it "should correctly patch left-to-right (explicit patch)" do
300
- Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch).should == @s2
301
- Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch).should == @s1
302
- Diff::LCS.patch!(@s1, @patch_set_s1_s2).should == @s2
303
- Diff::LCS.patch!(@s2, @patch_set_s2_s1).should == @s1
325
+ it 'correctly patches left-to-right (explicit patch)' do
326
+ expect(Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch)).to eq(@s2)
327
+ expect(Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch)).to eq(@s1)
328
+ expect(Diff::LCS.patch!(@s1, @patch_set_s1_s2)).to eq(@s2)
329
+ expect(Diff::LCS.patch!(@s2, @patch_set_s2_s1)).to eq(@s1)
304
330
  end
305
331
 
306
- it "should correctly patch right-to-left (explicit unpatch)" do
307
- Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch).should == @s1
308
- Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch).should == @s2
309
- Diff::LCS.unpatch!(@s2, @patch_set_s1_s2).should == @s1
310
- Diff::LCS.unpatch!(@s1, @patch_set_s2_s1).should == @s2
332
+ it 'correctly patches right-to-left (explicit unpatch)' do
333
+ expect(Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch)).to eq(@s1)
334
+ expect(Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch)).to eq(@s2)
335
+ expect(Diff::LCS.unpatch!(@s2, @patch_set_s1_s2)).to eq(@s1)
336
+ expect(Diff::LCS.unpatch!(@s1, @patch_set_s2_s1)).to eq(@s2)
311
337
  end
312
338
  end
313
339
 
314
- describe "using Diff::LCS.sdiff with context diff callbacks" do
340
+ describe 'using Diff::LCS.sdiff with context diff callbacks' do
315
341
  before(:each) do
316
342
  @patch_set_s1_s2 = Diff::LCS.sdiff(@s1, @s2, Diff::LCS::ContextDiffCallbacks)
317
343
  @patch_set_s2_s1 = Diff::LCS.sdiff(@s2, @s1, Diff::LCS::ContextDiffCallbacks)
318
344
  end
319
345
 
320
- it "does not autodiscover s1 to s2 patches" do
321
- # It should, but it doesn't.
346
+ it 'autodiscovers s1 to s2 patches' do
322
347
  expect do
323
- Diff::LCS.patch(@s1, @patch_set_s1_s2).should == @s2
324
- end.to raise_error(RuntimeError, /provided patchset/)
348
+ expect(Diff::LCS.patch(@s1, @patch_set_s1_s2)).to eq(@s2)
349
+ end.to_not raise_error
350
+ end
325
351
 
352
+ it 'autodiscovers s2 to s1 patches' do
326
353
  expect do
327
- Diff::LCS.patch(@s1, @patch_set_s2_s1).should == @s2
328
- end.to raise_error(RuntimeError, /provided patchset/)
354
+ expect(Diff::LCS.patch(@s1, @patch_set_s2_s1)).to eq(@s2)
355
+ end.to_not raise_error
329
356
  end
330
357
 
331
- it "should autodiscover s2 to s1 the left-to-right patches" do
332
- Diff::LCS.patch(@s2, @patch_set_s2_s1).should == @s1
333
- Diff::LCS.patch(@s2, @patch_set_s1_s2).should == @s1
358
+ it 'autodiscovers s2 to s1 the left-to-right patches' do
359
+ expect(Diff::LCS.patch(@s2, @patch_set_s2_s1)).to eq(@s1)
360
+ expect(Diff::LCS.patch(@s2, @patch_set_s1_s2)).to eq(@s1)
334
361
  end
335
362
 
336
- it "should correctly patch left-to-right (explicit patch)" do
337
- Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch).should == @s2
338
- Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch).should == @s1
339
- Diff::LCS.patch!(@s1, @patch_set_s1_s2).should == @s2
340
- Diff::LCS.patch!(@s2, @patch_set_s2_s1).should == @s1
363
+ it 'correctly patches left-to-right (explicit patch)' do
364
+ expect(Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch)).to eq(@s2)
365
+ expect(Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch)).to eq(@s1)
366
+ expect(Diff::LCS.patch!(@s1, @patch_set_s1_s2)).to eq(@s2)
367
+ expect(Diff::LCS.patch!(@s2, @patch_set_s2_s1)).to eq(@s1)
341
368
  end
342
369
 
343
- it "should correctly patch right-to-left (explicit unpatch)" do
344
- Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch).should == @s1
345
- Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch).should == @s2
346
- Diff::LCS.unpatch!(@s2, @patch_set_s1_s2).should == @s1
347
- Diff::LCS.unpatch!(@s1, @patch_set_s2_s1).should == @s2
370
+ it 'correctly patches right-to-left (explicit unpatch)' do
371
+ expect(Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch)).to eq(@s1)
372
+ expect(Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch)).to eq(@s2)
373
+ expect(Diff::LCS.unpatch!(@s2, @patch_set_s1_s2)).to eq(@s1)
374
+ expect(Diff::LCS.unpatch!(@s1, @patch_set_s2_s1)).to eq(@s2)
348
375
  end
349
376
  end
350
377
 
351
- describe "using Diff::LCS.sdiff with default diff callbacks" do
378
+ describe 'using Diff::LCS.sdiff with default diff callbacks' do
352
379
  before(:each) do
353
380
  @patch_set_s1_s2 = Diff::LCS.sdiff(@s1, @s2, Diff::LCS::DiffCallbacks)
354
381
  @patch_set_s2_s1 = Diff::LCS.sdiff(@s2, @s1, Diff::LCS::DiffCallbacks)
355
382
  end
356
383
 
357
- it "does not autodiscover s1 to s2 patches" do
358
- # It should, but it doesn't.
384
+ it 'autodiscovers s1 to s2 patches' do
359
385
  expect do
360
- Diff::LCS.patch(@s1, @patch_set_s1_s2).should == @s2
361
- end.to raise_error(RuntimeError, /provided patchset/)
386
+ expect(Diff::LCS.patch(@s1, @patch_set_s1_s2)).to eq(@s2)
387
+ end.to_not raise_error
388
+ end
362
389
 
390
+ it 'autodiscovers s2 to s1 patches' do
363
391
  expect do
364
- Diff::LCS.patch(@s1, @patch_set_s2_s1).should == @s2
365
- end.to raise_error(RuntimeError, /provided patchset/)
392
+ expect(Diff::LCS.patch(@s1, @patch_set_s2_s1)).to eq(@s2)
393
+ end.to_not raise_error
366
394
  end
367
395
 
368
- it "should autodiscover s2 to s1 the left-to-right patches" do
369
- Diff::LCS.patch(@s2, @patch_set_s2_s1).should == @s1
370
- Diff::LCS.patch(@s2, @patch_set_s1_s2).should == @s1
396
+ it 'autodiscovers s2 to s1 the left-to-right patches' do
397
+ expect(Diff::LCS.patch(@s2, @patch_set_s2_s1)).to eq(@s1)
398
+ expect(Diff::LCS.patch(@s2, @patch_set_s1_s2)).to eq(@s1)
371
399
  end
372
400
 
373
- it "should correctly patch left-to-right (explicit patch)" do
374
- Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch).should == @s2
375
- Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch).should == @s1
376
- Diff::LCS.patch!(@s1, @patch_set_s1_s2).should == @s2
377
- Diff::LCS.patch!(@s2, @patch_set_s2_s1).should == @s1
401
+ it 'correctly patches left-to-right (explicit patch)' do
402
+ expect(Diff::LCS.patch(@s1, @patch_set_s1_s2, :patch)).to eq(@s2)
403
+ expect(Diff::LCS.patch(@s2, @patch_set_s2_s1, :patch)).to eq(@s1)
404
+ expect(Diff::LCS.patch!(@s1, @patch_set_s1_s2)).to eq(@s2)
405
+ expect(Diff::LCS.patch!(@s2, @patch_set_s2_s1)).to eq(@s1)
378
406
  end
379
407
 
380
- it "should correctly patch right-to-left (explicit unpatch)" do
381
- Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch).should == @s1
382
- Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch).should == @s2
383
- Diff::LCS.unpatch!(@s2, @patch_set_s1_s2).should == @s1
384
- Diff::LCS.unpatch!(@s1, @patch_set_s2_s1).should == @s2
408
+ it 'correctly patches right-to-left (explicit unpatch)' do
409
+ expect(Diff::LCS.patch(@s2, @patch_set_s1_s2, :unpatch)).to eq(@s1)
410
+ expect(Diff::LCS.patch(@s1, @patch_set_s2_s1, :unpatch)).to eq(@s2)
411
+ expect(Diff::LCS.unpatch!(@s2, @patch_set_s1_s2)).to eq(@s1)
412
+ expect(Diff::LCS.unpatch!(@s1, @patch_set_s2_s1)).to eq(@s2)
385
413
  end
386
414
  end
387
415
  end
388
416
  end
389
-
390
- # vim: ft=ruby