diff-lcs 1.2.5 → 1.4.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +6 -14
  2. data/.rspec +0 -1
  3. data/Code-of-Conduct.md +74 -0
  4. data/Contributing.md +84 -0
  5. data/History.md +278 -0
  6. data/{License.rdoc → License.md} +0 -0
  7. data/Manifest.txt +15 -8
  8. data/README.rdoc +18 -19
  9. data/Rakefile +41 -25
  10. data/autotest/discover.rb +3 -1
  11. data/bin/htmldiff +7 -4
  12. data/bin/ldiff +4 -1
  13. data/lib/diff-lcs.rb +1 -1
  14. data/lib/diff/lcs.rb +181 -254
  15. data/lib/diff/lcs/array.rb +1 -1
  16. data/lib/diff/lcs/backports.rb +9 -0
  17. data/lib/diff/lcs/block.rb +2 -2
  18. data/lib/diff/lcs/callbacks.rb +15 -12
  19. data/lib/diff/lcs/change.rb +33 -36
  20. data/lib/diff/lcs/htmldiff.rb +17 -16
  21. data/lib/diff/lcs/hunk.rb +67 -52
  22. data/lib/diff/lcs/internals.rb +43 -40
  23. data/lib/diff/lcs/ldiff.rb +44 -64
  24. data/lib/diff/lcs/string.rb +1 -1
  25. data/spec/change_spec.rb +31 -7
  26. data/spec/diff_spec.rb +24 -20
  27. data/spec/fixtures/aX +1 -0
  28. data/spec/fixtures/bXaX +1 -0
  29. data/spec/fixtures/ds1.csv +50 -0
  30. data/spec/fixtures/ds2.csv +51 -0
  31. data/spec/fixtures/ldiff/output.diff +4 -0
  32. data/spec/fixtures/ldiff/output.diff-c +7 -0
  33. data/spec/fixtures/ldiff/output.diff-e +3 -0
  34. data/spec/fixtures/ldiff/output.diff-f +3 -0
  35. data/spec/fixtures/ldiff/output.diff-u +5 -0
  36. data/spec/hunk_spec.rb +37 -37
  37. data/spec/issues_spec.rb +91 -17
  38. data/spec/lcs_spec.rb +24 -22
  39. data/spec/ldiff_spec.rb +86 -0
  40. data/spec/patch_spec.rb +182 -180
  41. data/spec/sdiff_spec.rb +91 -91
  42. data/spec/spec_helper.rb +143 -58
  43. data/spec/traverse_balanced_spec.rb +177 -177
  44. data/spec/traverse_sequences_spec.rb +63 -63
  45. metadata +87 -143
  46. checksums.yaml.gz.sig +0 -0
  47. data.tar.gz.sig +0 -3
  48. data/.autotest +0 -3
  49. data/.gemtest +0 -0
  50. data/.hoerc +0 -2
  51. data/.travis.yml +0 -22
  52. data/Contributing.rdoc +0 -64
  53. data/Gemfile +0 -20
  54. data/History.rdoc +0 -152
  55. metadata.gz.sig +0 -2
@@ -0,0 +1,86 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe 'bin/ldiff' do
6
+ include CaptureSubprocessIO
7
+
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
+ let(:output_diff_chef) { read_fixture('-u', :base => 'output.diff.chef') }
14
+
15
+ specify do
16
+ expect(run_ldiff('-u', :left => 'old-chef', :right => 'new-chef')).to eq(output_diff_chef)
17
+ end
18
+
19
+ specify do
20
+ expect(run_ldiff).to eq(output_diff)
21
+ end
22
+
23
+ specify do
24
+ expect(run_ldiff('-c')).to eq(output_diff_c)
25
+ end
26
+
27
+ specify do
28
+ expect(run_ldiff('-e')).to eq(output_diff_e)
29
+ end
30
+
31
+ specify do
32
+ expect(run_ldiff('-f')).to eq(output_diff_f)
33
+ end
34
+
35
+ specify do
36
+ expect(run_ldiff('-u')).to eq(output_diff_u)
37
+ end
38
+
39
+ def read_fixture(flag = nil, options = {})
40
+ base = options.fetch(:base, 'output.diff')
41
+ name = "spec/fixtures/ldiff/#{base}#{flag}"
42
+ data = IO.__send__(IO.respond_to?(:binread) ? :binread : :read, name)
43
+ clean_data(data, flag)
44
+ end
45
+
46
+ def clean_data(data, flag)
47
+ data =
48
+ case flag
49
+ when '-c', '-u'
50
+ clean_output_timestamp(data)
51
+ else
52
+ data
53
+ end
54
+ data.gsub(/\r\n?/, "\n")
55
+ end
56
+
57
+ def clean_output_timestamp(data)
58
+ data.gsub(
59
+ %r{
60
+ ^
61
+ [-+*]{3}
62
+ \s*
63
+ spec/fixtures/(\S+)
64
+ \s*
65
+ \d{4}-\d\d-\d\d
66
+ \s*
67
+ \d\d:\d\d:\d\d(?:\.\d+)
68
+ \s*
69
+ (?:[-+]\d{4}|Z)
70
+ }x,
71
+ '*** spec/fixtures/\1 0000-00-00 00:00:00.000000000 -0000'
72
+ )
73
+ end
74
+
75
+ def run_ldiff(flag = nil, options = {})
76
+ left = options.fetch(:left, 'aX')
77
+ right = options.fetch(:right, 'bXaX')
78
+ stdout, stderr = capture_subprocess_io do
79
+ system("ruby -Ilib bin/ldiff #{flag} spec/fixtures/#{left} spec/fixtures/#{right}")
80
+ end
81
+
82
+ expect(stderr).to be_empty if RUBY_VERSION >= '1.9'
83
+ expect(stdout).not_to be_empty
84
+ clean_data(stdout, flag)
85
+ end
86
+ end
@@ -1,52 +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 "an empty patchset returns the source" do
30
- it "works on a string (hello)" do
31
- Diff::LCS::patch(hello, Diff::LCS.diff(hello, hello)).should == hello
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)
32
33
  end
33
34
 
34
- 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
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)
36
38
  end
37
39
  end
38
40
 
39
- describe "with default diff callbacks (DiffCallbacks)" do
40
- describe "forward (s1 -> s2)" do
41
- 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
42
44
  let(:s1) { seq1 }
43
45
  let(:s2) { seq2 }
44
46
  let(:patch_set) { Diff::LCS.diff(seq1, seq2) }
45
47
  end
46
48
  end
47
49
 
48
- describe "reverse (s2 -> s1)" do
49
- it_has_behavior "patch sequences correctly" do
50
+ describe 'reverse (s2 -> s1)' do
51
+ it_has_behavior 'patch sequences correctly' do
50
52
  let(:s1) { seq2 }
51
53
  let(:s2) { seq1 }
52
54
  let(:patch_set) { Diff::LCS.diff(seq2, seq1) }
@@ -54,9 +56,9 @@ describe "Diff::LCS.patch" do
54
56
  end
55
57
  end
56
58
 
57
- describe "with context diff callbacks (ContextDiffCallbacks)" do
58
- describe "forward (s1 -> s2)" do
59
- 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
60
62
  let(:s1) { seq1 }
61
63
  let(:s2) { seq2 }
62
64
  let(:patch_set) {
@@ -65,8 +67,8 @@ describe "Diff::LCS.patch" do
65
67
  end
66
68
  end
67
69
 
68
- describe "reverse (s2 -> s1)" do
69
- it_has_behavior "patch sequences correctly" do
70
+ describe 'reverse (s2 -> s1)' do
71
+ it_has_behavior 'patch sequences correctly' do
70
72
  let(:s1) { seq2 }
71
73
  let(:s2) { seq1 }
72
74
  let(:patch_set) {
@@ -76,9 +78,9 @@ describe "Diff::LCS.patch" do
76
78
  end
77
79
  end
78
80
 
79
- describe "with sdiff callbacks (SDiffCallbacks)" do
80
- describe "forward (s1 -> s2)" do
81
- 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
82
84
  let(:s1) { seq1 }
83
85
  let(:s2) { seq2 }
84
86
  let(:patch_set) {
@@ -87,8 +89,8 @@ describe "Diff::LCS.patch" do
87
89
  end
88
90
  end
89
91
 
90
- describe "reverse (s2 -> s1)" do
91
- it_has_behavior "patch sequences correctly" do
92
+ describe 'reverse (s2 -> s1)' do
93
+ it_has_behavior 'patch sequences correctly' do
92
94
  let(:s1) { seq2 }
93
95
  let(:s2) { seq1 }
94
96
  let(:patch_set) {
@@ -99,20 +101,20 @@ describe "Diff::LCS.patch" do
99
101
  end
100
102
  end
101
103
 
102
- describe "using a Diff::LCS.sdiff patchset" do
103
- describe "an empty patchset returns the source" do
104
- it "works on a string (hello)" do
105
- Diff::LCS::patch(hello, Diff::LCS.sdiff(hello, hello)).should == 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)
106
108
  end
107
109
 
108
- 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
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
112
  end
111
113
  end
112
114
 
113
- describe "with default diff callbacks (DiffCallbacks)" do
114
- describe "forward (s1 -> s2)" do
115
- 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
116
118
  let(:s1) { seq1 }
117
119
  let(:s2) { seq2 }
118
120
  let(:patch_set) {
@@ -121,8 +123,8 @@ describe "Diff::LCS.patch" do
121
123
  end
122
124
  end
123
125
 
124
- describe "reverse (s2 -> s1)" do
125
- it_has_behavior "patch sequences correctly" do
126
+ describe 'reverse (s2 -> s1)' do
127
+ it_has_behavior 'patch sequences correctly' do
126
128
  let(:s1) { seq2 }
127
129
  let(:s2) { seq1 }
128
130
  let(:patch_set) {
@@ -132,9 +134,9 @@ describe "Diff::LCS.patch" do
132
134
  end
133
135
  end
134
136
 
135
- describe "with context diff callbacks (DiffCallbacks)" do
136
- describe "forward (s1 -> s2)" do
137
- 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
138
140
  let(:s1) { seq1 }
139
141
  let(:s2) { seq2 }
140
142
  let(:patch_set) {
@@ -143,8 +145,8 @@ describe "Diff::LCS.patch" do
143
145
  end
144
146
  end
145
147
 
146
- describe "reverse (s2 -> s1)" do
147
- it_has_behavior "patch sequences correctly" do
148
+ describe 'reverse (s2 -> s1)' do
149
+ it_has_behavior 'patch sequences correctly' do
148
150
  let(:s1) { seq2 }
149
151
  let(:s2) { seq1 }
150
152
  let(:patch_set) {
@@ -154,17 +156,17 @@ describe "Diff::LCS.patch" do
154
156
  end
155
157
  end
156
158
 
157
- describe "with sdiff callbacks (SDiffCallbacks)" do
158
- describe "forward (s1 -> s2)" do
159
- 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
160
162
  let(:s1) { seq1 }
161
163
  let(:s2) { seq2 }
162
164
  let(:patch_set) { Diff::LCS.sdiff(seq1, seq2) }
163
165
  end
164
166
  end
165
167
 
166
- describe "reverse (s2 -> s1)" do
167
- it_has_behavior "patch sequences correctly" do
168
+ describe 'reverse (s2 -> s1)' do
169
+ it_has_behavior 'patch sequences correctly' do
168
170
  let(:s1) { seq2 }
169
171
  let(:s2) { seq1 }
170
172
  let(:patch_set) { Diff::LCS.sdiff(seq2, seq1) }
@@ -177,237 +179,237 @@ describe "Diff::LCS.patch" do
177
179
  # to s2 patches"), this cannot use the "patch sequences correctly" shared
178
180
  # set. Once the bug in autodiscovery is fixed, this can be converted as
179
181
  # above.
180
- describe "fix bug 891: patchsets do not contain the last equal part" do
181
- before(:each) do
182
- @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
183
185
  @s2 = %w(a b c d D e f g h i j k)
184
186
  end
185
187
 
186
- describe "using Diff::LCS.diff with default diff callbacks" do
187
- before(:each) do
188
+ describe 'using Diff::LCS.diff with default diff callbacks' 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
- describe "using Diff::LCS.diff with context diff callbacks" do
225
- before(:each) do
226
+ describe 'using Diff::LCS.diff with context diff callbacks' do
227
+ before :each do
226
228
  @patch_set_s1_s2 = Diff::LCS.diff(@s1, @s2, Diff::LCS::ContextDiffCallbacks)
227
229
  @patch_set_s2_s1 = Diff::LCS.diff(@s2, @s1, Diff::LCS::ContextDiffCallbacks)
228
230
  end
229
231
 
230
- it "should autodiscover s1 to s2 patches" do
232
+ it 'autodiscovers s1 to s2 patches' do
231
233
  expect do
232
- Diff::LCS.patch(@s1, @patch_set_s1_s2).should == @s2
233
- end.to_not raise_error(RuntimeError, /provided patchset/)
234
+ expect(Diff::LCS.patch(@s1, @patch_set_s1_s2)).to eq(@s2)
235
+ end.to_not raise_error
234
236
  end
235
237
 
236
- it "should autodiscover s2 to s1 patches" do
238
+ it 'autodiscovers s2 to s1 patches' do
237
239
  expect do
238
- Diff::LCS.patch(@s1, @patch_set_s2_s1).should == @s2
239
- end.to_not raise_error(RuntimeError, /provided patchset/)
240
+ expect(Diff::LCS.patch(@s1, @patch_set_s2_s1)).to eq(@s2)
241
+ end.to_not raise_error
240
242
  end
241
243
 
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
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)
245
247
  end
246
248
 
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
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)
252
254
  end
253
255
 
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
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)
259
261
  end
260
262
  end
261
263
 
262
- describe "using Diff::LCS.diff with sdiff callbacks" do
264
+ describe 'using Diff::LCS.diff with sdiff callbacks' do
263
265
  before(:each) do
264
266
  @patch_set_s1_s2 = Diff::LCS.diff(@s1, @s2, Diff::LCS::SDiffCallbacks)
265
267
  @patch_set_s2_s1 = Diff::LCS.diff(@s2, @s1, Diff::LCS::SDiffCallbacks)
266
268
  end
267
269
 
268
- it "should autodiscover s1 to s2 patches" do
270
+ it 'autodiscovers s1 to s2 patches' do
269
271
  expect do
270
- Diff::LCS.patch(@s1, @patch_set_s1_s2).should == @s2
271
- end.to_not raise_error(RuntimeError, /provided patchset/)
272
+ expect(Diff::LCS.patch(@s1, @patch_set_s1_s2)).to eq(@s2)
273
+ end.to_not raise_error
272
274
  end
273
275
 
274
- it "should autodiscover s2 to s1 patches" do
276
+ it 'autodiscovers s2 to s1 patches' do
275
277
  expect do
276
- Diff::LCS.patch(@s1, @patch_set_s2_s1).should == @s2
277
- end.to_not raise_error(RuntimeError, /provided patchset/)
278
+ expect(Diff::LCS.patch(@s1, @patch_set_s2_s1)).to eq(@s2)
279
+ end.to_not raise_error
278
280
  end
279
281
 
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
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)
283
285
  end
284
286
 
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
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)
290
292
  end
291
293
 
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
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)
297
299
  end
298
300
  end
299
301
 
300
- describe "using Diff::LCS.sdiff with default sdiff callbacks" do
302
+ describe 'using Diff::LCS.sdiff with default sdiff callbacks' do
301
303
  before(:each) do
302
304
  @patch_set_s1_s2 = Diff::LCS.sdiff(@s1, @s2)
303
305
  @patch_set_s2_s1 = Diff::LCS.sdiff(@s2, @s1)
304
306
  end
305
307
 
306
- it "should autodiscover s1 to s2 patches" do
308
+ it 'autodiscovers s1 to s2 patches' do
307
309
  expect do
308
- Diff::LCS.patch(@s1, @patch_set_s1_s2).should == @s2
309
- end.to_not raise_error(RuntimeError, /provided patchset/)
310
+ expect(Diff::LCS.patch(@s1, @patch_set_s1_s2)).to eq(@s2)
311
+ end.to_not raise_error
310
312
  end
311
313
 
312
- it "should autodiscover s2 to s1 patches" do
314
+ it 'autodiscovers s2 to s1 patches' do
313
315
  expect do
314
- Diff::LCS.patch(@s1, @patch_set_s2_s1).should == @s2
315
- end.to_not raise_error(RuntimeError, /provided patchset/)
316
+ expect(Diff::LCS.patch(@s1, @patch_set_s2_s1)).to eq(@s2)
317
+ end.to_not raise_error
316
318
  end
317
319
 
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
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)
321
323
  end
322
324
 
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
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)
328
330
  end
329
331
 
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
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)
335
337
  end
336
338
  end
337
339
 
338
- describe "using Diff::LCS.sdiff with context diff callbacks" do
340
+ describe 'using Diff::LCS.sdiff with context diff callbacks' do
339
341
  before(:each) do
340
342
  @patch_set_s1_s2 = Diff::LCS.sdiff(@s1, @s2, Diff::LCS::ContextDiffCallbacks)
341
343
  @patch_set_s2_s1 = Diff::LCS.sdiff(@s2, @s1, Diff::LCS::ContextDiffCallbacks)
342
344
  end
343
345
 
344
- it "should autodiscover s1 to s2 patches" do
346
+ it 'autodiscovers s1 to s2 patches' do
345
347
  expect do
346
- Diff::LCS.patch(@s1, @patch_set_s1_s2).should == @s2
347
- end.to_not raise_error(RuntimeError, /provided patchset/)
348
+ expect(Diff::LCS.patch(@s1, @patch_set_s1_s2)).to eq(@s2)
349
+ end.to_not raise_error
348
350
  end
349
351
 
350
- it "should autodiscover s2 to s1 patches" do
352
+ it 'autodiscovers s2 to s1 patches' do
351
353
  expect do
352
- Diff::LCS.patch(@s1, @patch_set_s2_s1).should == @s2
353
- end.to_not raise_error(RuntimeError, /provided patchset/)
354
+ expect(Diff::LCS.patch(@s1, @patch_set_s2_s1)).to eq(@s2)
355
+ end.to_not raise_error
354
356
  end
355
357
 
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
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)
359
361
  end
360
362
 
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
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)
366
368
  end
367
369
 
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
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)
373
375
  end
374
376
  end
375
377
 
376
- describe "using Diff::LCS.sdiff with default diff callbacks" do
378
+ describe 'using Diff::LCS.sdiff with default diff callbacks' do
377
379
  before(:each) do
378
380
  @patch_set_s1_s2 = Diff::LCS.sdiff(@s1, @s2, Diff::LCS::DiffCallbacks)
379
381
  @patch_set_s2_s1 = Diff::LCS.sdiff(@s2, @s1, Diff::LCS::DiffCallbacks)
380
382
  end
381
383
 
382
- it "should autodiscover s1 to s2 patches" do
384
+ it 'autodiscovers s1 to s2 patches' do
383
385
  expect do
384
- Diff::LCS.patch(@s1, @patch_set_s1_s2).should == @s2
385
- end.to_not raise_error(RuntimeError, /provided patchset/)
386
+ expect(Diff::LCS.patch(@s1, @patch_set_s1_s2)).to eq(@s2)
387
+ end.to_not raise_error
386
388
  end
387
389
 
388
- it "should autodiscover s2 to s1 patches" do
390
+ it 'autodiscovers s2 to s1 patches' do
389
391
  expect do
390
- Diff::LCS.patch(@s1, @patch_set_s2_s1).should == @s2
391
- end.to_not raise_error(RuntimeError, /provided patchset/)
392
+ expect(Diff::LCS.patch(@s1, @patch_set_s2_s1)).to eq(@s2)
393
+ end.to_not raise_error
392
394
  end
393
395
 
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
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)
397
399
  end
398
400
 
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
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)
404
406
  end
405
407
 
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
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)
411
413
  end
412
414
  end
413
415
  end