summaryrefslogtreecommitdiff
path: root/spec/ruby/core/proc
diff options
context:
space:
mode:
authorBenoit Daloze <eregontp@gmail.com>2020-06-27 15:51:37 +0200
committerBenoit Daloze <eregontp@gmail.com>2020-06-27 15:51:37 +0200
commitb3fa158d1c4d8e03b8dc04f1e4f9940a8a4ef44c (patch)
treefa8a62d6192c24a21e70aa02589507adfe4e4e6a /spec/ruby/core/proc
parent64d8c0815e6ab042e8a67a670bda9f34404fa662 (diff)
Update to ruby/spec@b6b7752
Diffstat (limited to 'spec/ruby/core/proc')
-rw-r--r--spec/ruby/core/proc/new_spec.rb14
-rw-r--r--spec/ruby/core/proc/parameters_spec.rb4
-rw-r--r--spec/ruby/core/proc/shared/call_arguments.rb2
3 files changed, 16 insertions, 4 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
diff --git a/spec/ruby/core/proc/parameters_spec.rb b/spec/ruby/core/proc/parameters_spec.rb
index 2bc5f1325c..5fb5cf418d 100644
--- a/spec/ruby/core/proc/parameters_spec.rb
+++ b/spec/ruby/core/proc/parameters_spec.rb
@@ -57,7 +57,7 @@ describe "Proc#parameters" do
end
it "sets the first element of each sub-Array to :block for parameters prefixed with ampersands" do
- ->&x { }.parameters.first.first.should == :block
+ -> &x { }.parameters.first.first.should == :block
-> x, &y { }.parameters.last.first.should == :block
proc {|&x| }.parameters.first.first.should == :block
proc {|x,&y| }.parameters.last.first.should == :block
@@ -68,7 +68,7 @@ describe "Proc#parameters" do
-> x=Math::PI { }.parameters.first.last.should == :x
-> an_argument, glark, &foo { }.parameters[1].last.should == :glark
-> *rest { }.parameters.first.last.should == :rest
- ->&block { }.parameters.first.last.should == :block
+ -> &block { }.parameters.first.last.should == :block
proc {|x| }.parameters.first.last.should == :x
proc {|x=Math::PI| }.parameters.first.last.should == :x
proc {|an_argument, glark, &foo| }.parameters[1].last.should == :glark
diff --git a/spec/ruby/core/proc/shared/call_arguments.rb b/spec/ruby/core/proc/shared/call_arguments.rb
index ef6ec04620..91ada3439e 100644
--- a/spec/ruby/core/proc/shared/call_arguments.rb
+++ b/spec/ruby/core/proc/shared/call_arguments.rb
@@ -1,7 +1,7 @@
describe :proc_call_block_args, shared: true do
it "can receive block arguments" do
Proc.new {|&b| b.send(@method)}.send(@method) {1 + 1}.should == 2
- ->&b { b.send(@method)}.send(@method) {1 + 1}.should == 2
+ -> &b { b.send(@method)}.send(@method) {1 + 1}.should == 2
proc {|&b| b.send(@method)}.send(@method) {1 + 1}.should == 2
end