1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
This commit is contained in:
Benoit Daloze 2020-06-27 15:51:37 +02:00
parent 64d8c0815e
commit b3fa158d1c
35 changed files with 652 additions and 56 deletions

View file

@ -203,7 +203,7 @@ describe "Proc.new without a block" do
end
end
ruby_version_is "2.7" ... "2.8" do
ruby_version_is "2.7"..."2.8" do
it "can be created if invoked from within a method with a block" do
-> { ProcSpecs.new_proc_in_method { "hello" } }.should complain(/Capturing the given block using Proc.new is deprecated/)
end
@ -223,4 +223,16 @@ describe "Proc.new without a block" do
}.should complain(/Capturing the given block using Proc.new is deprecated/)
end
end
ruby_version_is "2.8" do
it "raises an ArgumentError when passed no block" do
def some_method
Proc.new
end
-> { ProcSpecs.new_proc_in_method { "hello" } }.should raise_error(ArgumentError, 'tried to create Proc object without a block')
-> { ProcSpecs.new_proc_subclass_in_method { "hello" } }.should raise_error(ArgumentError, 'tried to create Proc object without a block')
-> { some_method { "hello" } }.should raise_error(ArgumentError, 'tried to create Proc object without a block')
end
end
end