diff options
Diffstat (limited to 'spec/ruby/core/proc/new_spec.rb')
-rw-r--r-- | spec/ruby/core/proc/new_spec.rb | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/spec/ruby/core/proc/new_spec.rb b/spec/ruby/core/proc/new_spec.rb index faaf85fea5..0a6247239f 100644 --- a/spec/ruby/core/proc/new_spec.rb +++ b/spec/ruby/core/proc/new_spec.rb @@ -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 |