Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Commit 002b77b

Browse files
committed
Remove DiffHelpers
1 parent 855d786 commit 002b77b

File tree

4 files changed

+56
-106
lines changed

4 files changed

+56
-106
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
- 2.3
3131
env:
3232
-
33-
DIFF_LCS_VERSION: "> 1.4.3"
33+
BOGUS: ""
3434
include:
3535
- ruby: ruby-head
3636
env:

Gemfile

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@ branch = File.read(File.expand_path("../maintenance-branch", __FILE__)).chomp
1313
end
1414
end
1515

16-
if ENV['DIFF_LCS_VERSION']
17-
gem 'diff-lcs', ENV['DIFF_LCS_VERSION']
18-
else
19-
gem 'diff-lcs', '~> 1.4', '>= 1.4.3'
20-
end
21-
2216
gem "childprocess", ">= 3.0.0"
2317
gem 'ffi', '~> 1.12.0'
2418

lib/rspec/support/spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
require 'rspec/support/spec/in_sub_process'
33

44
RSpec::Support.require_rspec_support "spec/deprecation_helpers"
5-
RSpec::Support.require_rspec_support "spec/diff_helpers"
65
RSpec::Support.require_rspec_support "spec/with_isolated_stderr"
76
RSpec::Support.require_rspec_support "spec/stderr_splitter"
87
RSpec::Support.require_rspec_support "spec/formatting_support"

spec/rspec/support/differ_spec.rb

Lines changed: 55 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -5,55 +5,32 @@
55
module RSpec
66
module Support
77
RSpec.describe Differ do
8-
include Spec::DiffHelpers
9-
108
describe '#diff' do
119
let(:differ) { RSpec::Support::Differ.new }
1210

1311
it "outputs unified diff of two strings" do
1412
expected = "foo\nzap\nbar\nthis\nis\nsoo\nvery\nvery\nequal\ninsert\na\nanother\nline\n"
1513
actual = "foo\nbar\nzap\nthis\nis\nsoo\nvery\nvery\nequal\ninsert\na\nline\n"
1614

17-
if Diff::LCS::VERSION.to_f < 1.4 || Diff::LCS::VERSION >= "1.4.4"
18-
expected_diff = dedent(<<-'EOD')
19-
|
20-
|
21-
|@@ -1,6 +1,6 @@
22-
| foo
23-
|-zap
24-
| bar
25-
|+zap
26-
| this
27-
| is
28-
| soo
29-
|@@ -9,6 +9,5 @@
30-
| equal
31-
| insert
32-
| a
33-
|-another
34-
| line
35-
|
36-
EOD
37-
else
38-
expected_diff = dedent(<<-'EOD')
39-
|
40-
|
41-
|@@ -1,4 +1,6 @@
42-
| foo
43-
|-zap
44-
| bar
45-
|+zap
46-
| this
47-
|@@ -9,6 +11,7 @@
48-
| equal
49-
| insert
50-
| a
51-
|-another
52-
| line
53-
|
54-
EOD
55-
end
56-
15+
expected_diff = dedent(<<-'EOD')
16+
|
17+
|
18+
|@@ -1,6 +1,6 @@
19+
| foo
20+
|-zap
21+
| bar
22+
|+zap
23+
| this
24+
| is
25+
| soo
26+
|@@ -9,6 +9,5 @@
27+
| equal
28+
| insert
29+
| a
30+
|-another
31+
| line
32+
|
33+
EOD
5734

5835
diff = differ.diff(actual, expected)
5936
expect(diff).to be_diffed_as(expected_diff)
@@ -63,45 +40,25 @@ module Support
6340
expected = "foo\nzap\nbar\nthis\nis\nsoo\nvery\nvery\nequal\ninsert\na\nanother\nline\n"
6441
actual = "foo\nbar\nzap\nthis\nis\nsoo\nvery\nvery\nequal\ninsert\na\nline\n"
6542

66-
if Diff::LCS::VERSION.to_f < 1.4 || Diff::LCS::VERSION >= "1.4.4"
67-
expected_diff = dedent(<<-'EOS')
68-
|
69-
|
70-
|@@ -1,6 +1,6 @@
71-
| foo
72-
|-zap
73-
| bar
74-
|+zap
75-
| this
76-
| is
77-
| soo
78-
|@@ -9,6 +9,5 @@
79-
| equal
80-
| insert
81-
| a
82-
|-another
83-
| line
84-
|
85-
EOS
86-
else
87-
expected_diff = dedent(<<-'EOS')
88-
|
89-
|
90-
|@@ -1,4 +1,6 @@
91-
| foo
92-
|-zap
93-
| bar
94-
|+zap
95-
| this
96-
|@@ -9,6 +11,7 @@
97-
| equal
98-
| insert
99-
| a
100-
|-another
101-
| line
102-
|
103-
EOS
104-
end
43+
expected_diff = dedent(<<-'EOS')
44+
|
45+
|
46+
|@@ -1,6 +1,6 @@
47+
| foo
48+
|-zap
49+
| bar
50+
|+zap
51+
| this
52+
| is
53+
| soo
54+
|@@ -9,6 +9,5 @@
55+
| equal
56+
| insert
57+
| a
58+
|-another
59+
| line
60+
|
61+
EOS
10562

10663
diff = differ.diff(actual, expected)
10764
expect(diff).to be_diffed_as(expected_diff)
@@ -133,7 +90,7 @@ def differ_ivars
13390
actual = "Tu avec carté {count} itém has\n".encode('UTF-16LE')
13491
expected_diff = dedent(<<-EOD).encode('UTF-16LE')
13592
|
136-
|@@ #{one_line_header} @@
93+
|@@ -1 +1 @@
13794
|-Tu avec carte {count} item has
13895
|+Tu avec carté {count} itém has
13996
|
@@ -146,15 +103,15 @@ def differ_ivars
146103
it 'handles differently encoded strings that are compatible' do
147104
expected = "abc\n".encode('us-ascii')
148105
actual = "강인철\n".encode('UTF-8')
149-
expected_diff = "\n@@ #{one_line_header} @@\n-abc\n+강인철\n"
106+
expected_diff = "\n@@ -1 +1 @@\n-abc\n+강인철\n"
150107
diff = differ.diff(actual, expected)
151108
expect(diff).to be_diffed_as(expected_diff)
152109
end
153110

154111
it 'uses the default external encoding when the two strings have incompatible encodings' do
155112
expected = "Tu avec carte {count} item has\n"
156113
actual = "Tu avec carté {count} itém has\n".encode('UTF-16LE')
157-
expected_diff = "\n@@ #{one_line_header} @@\n-Tu avec carte {count} item has\n+Tu avec carté {count} itém has\n"
114+
expected_diff = "\n@@ -1 +1 @@\n-Tu avec carte {count} item has\n+Tu avec carté {count} itém has\n"
158115

159116
diff = differ.diff(actual, expected)
160117
expect(diff).to be_diffed_as(expected_diff)
@@ -245,7 +202,7 @@ def inspect; "<BrokenObject>"; end
245202

246203
expected_diff = dedent(<<-EOD)
247204
|
248-
|@@ #{one_line_header} @@
205+
|@@ -1 +1 @@
249206
|-[]
250207
|+[<BrokenObject>]
251208
|
@@ -257,7 +214,7 @@ def inspect; "<BrokenObject>"; end
257214
diff = differ.diff(["a\r\nb"], ["a\r\nc"])
258215
expected_diff = dedent(<<-EOD)
259216
|
260-
|@@ #{one_line_header} @@
217+
|@@ -1 +1 @@
261218
|-a\\r\\nc
262219
|+a\\r\\nb
263220
|
@@ -308,7 +265,7 @@ def inspect; "<BrokenObject>"; end
308265
it 'outputs unified diff message of two hashes with differing encoding' do
309266
expected_diff = dedent(<<-"EOD")
310267
|
311-
|@@ #{one_line_header} @@
268+
|@@ -1 +1 @@
312269
|-"a" => "a",
313270
|+"ö" => "ö",
314271
|
@@ -321,7 +278,7 @@ def inspect; "<BrokenObject>"; end
321278
it 'outputs unified diff message of two hashes with encoding different to key encoding' do
322279
expected_diff = dedent(<<-"EOD")
323280
|
324-
|@@ #{one_line_header} @@
281+
|@@ -1 +1 @@
325282
|-:a => "a",
326283
|+\"한글\" => \"한글2\",
327284
|
@@ -334,7 +291,7 @@ def inspect; "<BrokenObject>"; end
334291
it "outputs unified diff message of two hashes with object keys" do
335292
expected_diff = dedent(<<-"EOD")
336293
|
337-
|@@ #{one_line_header} @@
294+
|@@ -1 +1 @@
338295
|-["a", "c"] => "b",
339296
|+["d", "c"] => "b",
340297
|
@@ -351,7 +308,7 @@ def inspect; "<BrokenObject>"; end
351308
it "outputs unified diff message of two hashes with Time object keys" do
352309
expected_diff = dedent(<<-"EOD")
353310
|
354-
|@@ #{one_line_header} @@
311+
|@@ -1 +1 @@
355312
|-#{formatted_time} => "b",
356313
|+#{formatted_time} => "c",
357314
|
@@ -364,7 +321,7 @@ def inspect; "<BrokenObject>"; end
364321
it "outputs unified diff message of two hashes with hashes inside them" do
365322
expected_diff = dedent(<<-"EOD")
366323
|
367-
|@@ #{one_line_header} @@
324+
|@@ -1 +1 @@
368325
|-"b" => {"key_1"=>#{formatted_time}},
369326
|+"c" => {"key_1"=>#{formatted_time}},
370327
|
@@ -384,7 +341,7 @@ def inspect; "<BrokenObject>"; end
384341
it "outputs unified diff message of two arrays with Time object keys" do
385342
expected_diff = dedent(<<-"EOD")
386343
|
387-
|@@ #{one_line_header} @@
344+
|@@ -1 +1 @@
388345
|-[#{formatted_time}, "b"]
389346
|+[#{formatted_time}, "c"]
390347
|
@@ -397,7 +354,7 @@ def inspect; "<BrokenObject>"; end
397354
it "outputs unified diff message of two arrays with hashes inside them" do
398355
expected_diff = dedent(<<-"EOD")
399356
|
400-
|@@ #{one_line_header} @@
357+
|@@ -1 +1 @@
401358
|-[{"b"=>#{formatted_time}}, "c"]
402359
|+[{"a"=>#{formatted_time}}, "c"]
403360
|
@@ -430,7 +387,7 @@ def inspect; "<BrokenObject>"; end
430387
it "splits items with newlines" do
431388
expected_diff = dedent(<<-"EOD")
432389
|
433-
|@@ #{removing_two_line_header} @@
390+
|@@ -1,3 +1 @@
434391
|-a\\nb
435392
|-c\\nd
436393
|
@@ -443,7 +400,7 @@ def inspect; "<BrokenObject>"; end
443400
it "shows inner arrays on a single line" do
444401
expected_diff = dedent(<<-"EOD")
445402
|
446-
|@@ #{removing_two_line_header} @@
403+
|@@ -1,3 +1 @@
447404
|-a\\nb
448405
|-["c\\nd"]
449406
|
@@ -496,7 +453,7 @@ def inspect; "<BrokenObject>"; end
496453

497454
expected_diff = dedent(<<-EOS)
498455
|
499-
|@@ #{one_line_header} @@
456+
|@@ -1 +1 @@
500457
|-[#<SimpleDelegator(#{object.inspect})>]
501458
|+[#{object.inspect}]
502459
|
@@ -518,7 +475,7 @@ def inspect; "<BrokenObject>"; end
518475

519476
expected_diff = dedent(<<-EOS)
520477
|
521-
|@@ #{one_line_header} @@
478+
|@@ -1 +1 @@
522479
|-"oop"
523480
|+"oof"
524481
|
@@ -535,7 +492,7 @@ def inspect; "<BrokenObject>"; end
535492
it "outputs colored diffs" do
536493
expected = "foo bar baz\n"
537494
actual = "foo bang baz\n"
538-
expected_diff = "\e[0m\n\e[0m\e[34m@@ #{one_line_header} @@\n\e[0m\e[31m-foo bang baz\n\e[0m\e[32m+foo bar baz\n\e[0m"
495+
expected_diff = "\e[0m\n\e[0m\e[34m@@ -1 +1 @@\n\e[0m\e[31m-foo bang baz\n\e[0m\e[32m+foo bar baz\n\e[0m"
539496

540497
diff = differ.diff(expected,actual)
541498
expect(diff).to be_diffed_as(expected_diff)

0 commit comments

Comments
 (0)