Skip to content

Commit a520c87

Browse files
nobueregon
authored andcommitted
Refined "Drop support for ruby 2.4 from ruby/spec"
By using spec/mspec/tool/remove_old_guards.rb.
1 parent 41efca2 commit a520c87

File tree

9 files changed

+196
-162
lines changed

9 files changed

+196
-162
lines changed

command_line/dash_l_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
it "chomps last line based on $/" do
1515
ruby_exe('BEGIN { $/ = "ones\n" }; puts $_', options: "-W0 -n -l", escape: true,
1616
args: " < #{@names}").should ==
17-
"alice j\nbob field\njames grey\n"
17+
"alice j\nbob field\njames grey\n"
1818
end
1919

2020
it "sets $\\ to the value of $/" do

core/dir/shared/glob.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,10 +296,10 @@
296296
@mock_dir = File.expand_path tmp('dir_glob_mock')
297297

298298
%w[
299-
a/b/x
300-
a/b/c/y
301-
a/b/c/d/z
302-
].each do |path|
299+
a/b/x
300+
a/b/c/y
301+
a/b/c/d/z
302+
].each do |path|
303303
file = File.join @mock_dir, path
304304
mkdir_p File.dirname(file)
305305
touch file

core/file/utime_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
describe "File.utime" do
44

55
before :all do
6-
@time_is_float = /mswin|mingw/ =~ RUBY_PLATFORM && RUBY_VERSION >= '2.5'
6+
@time_is_float = /mswin|mingw/ =~ RUBY_PLATFORM
77
end
88

99
before :each do

core/integer/pow_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
end
2424

2525
it "handles sign like #divmod does" do
26-
2.pow(5, 12).should == 8
27-
2.pow(5, -12).should == -4
26+
2.pow(5, 12).should == 8
27+
2.pow(5, -12).should == -4
2828
-2.pow(5, 12).should == 4
2929
-2.pow(5, -12).should == -8
3030
end

core/integer/shared/arithmetic_coerce.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
11
require_relative '../fixtures/classes'
22

3+
describe :integer_arithmetic_coerce_rescue, shared: true do
4+
it "rescues exception (StandardError and subclasses) raised in other#coerce and raises TypeError" do
5+
b = mock("numeric with failed #coerce")
6+
b.should_receive(:coerce).and_raise(IntegerSpecs::CoerceError)
7+
8+
# e.g. 1 + b
9+
-> { 1.send(@method, b) }.should raise_error(TypeError, /MockObject can't be coerced into Integer/)
10+
end
11+
12+
it "does not rescue Exception and StandardError siblings raised in other#coerce" do
13+
[Exception, NoMemoryError].each do |exception|
14+
b = mock("numeric with failed #coerce")
15+
b.should_receive(:coerce).and_raise(exception)
16+
17+
# e.g. 1 + b
18+
-> { 1.send(@method, b) }.should raise_error(exception)
19+
end
20+
end
21+
end
22+
323
describe :integer_arithmetic_coerce_not_rescue, shared: true do
424
it "does not rescue exception raised in other#coerce" do
525
b = mock("numeric with failed #coerce")

language/ensure_spec.rb

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -259,72 +259,72 @@ class EnsureInClassExample
259259
it "is executed when an exception is raised in it's corresponding begin block" do
260260
-> {
261261
eval(<<-ruby).call
262-
lambda do
263-
ScratchPad << :begin
264-
raise EnsureSpec::Error
265-
ensure
266-
ScratchPad << :ensure
267-
end
268-
ruby
262+
lambda do
263+
ScratchPad << :begin
264+
raise EnsureSpec::Error
265+
ensure
266+
ScratchPad << :ensure
267+
end
268+
ruby
269269
}.should raise_error(EnsureSpec::Error)
270270

271271
ScratchPad.recorded.should == [:begin, :ensure]
272272
end
273273

274274
it "is executed when an exception is raised and rescued in it's corresponding begin block" do
275275
eval(<<-ruby).call
276-
lambda do
277-
ScratchPad << :begin
278-
raise "An exception occurred!"
279-
rescue
280-
ScratchPad << :rescue
281-
ensure
282-
ScratchPad << :ensure
283-
end
284-
ruby
276+
lambda do
277+
ScratchPad << :begin
278+
raise "An exception occurred!"
279+
rescue
280+
ScratchPad << :rescue
281+
ensure
282+
ScratchPad << :ensure
283+
end
284+
ruby
285285

286286
ScratchPad.recorded.should == [:begin, :rescue, :ensure]
287287
end
288288

289289
it "is executed even when a symbol is thrown in it's corresponding begin block" do
290290
catch(:symbol) do
291291
eval(<<-ruby).call
292-
lambda do
293-
ScratchPad << :begin
294-
throw(:symbol)
295-
rescue
296-
ScratchPad << :rescue
297-
ensure
298-
ScratchPad << :ensure
299-
end
300-
ruby
301-
end
302-
303-
ScratchPad.recorded.should == [:begin, :ensure]
304-
end
305-
306-
it "is executed when nothing is raised or thrown in it's corresponding begin block" do
307-
eval(<<-ruby).call
308292
lambda do
309293
ScratchPad << :begin
294+
throw(:symbol)
310295
rescue
311296
ScratchPad << :rescue
312297
ensure
313298
ScratchPad << :ensure
314299
end
315300
ruby
301+
end
302+
303+
ScratchPad.recorded.should == [:begin, :ensure]
304+
end
305+
306+
it "is executed when nothing is raised or thrown in it's corresponding begin block" do
307+
eval(<<-ruby).call
308+
lambda do
309+
ScratchPad << :begin
310+
rescue
311+
ScratchPad << :rescue
312+
ensure
313+
ScratchPad << :ensure
314+
end
315+
ruby
316316

317317
ScratchPad.recorded.should == [:begin, :ensure]
318318
end
319319

320320
it "has no return value" do
321321
result = eval(<<-ruby).call
322-
lambda do
323-
:begin
324-
ensure
325-
:ensure
326-
end
327-
ruby
322+
lambda do
323+
:begin
324+
ensure
325+
:ensure
326+
end
327+
ruby
328328

329329
result.should == :begin
330330
end

language/rescue_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -437,12 +437,12 @@ class RescueInClassExample
437437

438438
it "allows rescue in 'do end' block" do
439439
lambda = eval <<-ruby
440-
lambda do
441-
raise SpecificExampleException
442-
rescue SpecificExampleException
443-
ScratchPad << :caught
444-
end.call
445-
ruby
440+
lambda do
441+
raise SpecificExampleException
442+
rescue SpecificExampleException
443+
ScratchPad << :caught
444+
end.call
445+
ruby
446446

447447
ScratchPad.recorded.should == [:caught]
448448
end

0 commit comments

Comments
 (0)