diff options
Diffstat (limited to 'spec/ruby/language/method_spec.rb')
-rw-r--r-- | spec/ruby/language/method_spec.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/spec/ruby/language/method_spec.rb b/spec/ruby/language/method_spec.rb index bc7b8b6606..e31f3032b0 100644 --- a/spec/ruby/language/method_spec.rb +++ b/spec/ruby/language/method_spec.rb @@ -156,6 +156,26 @@ describe "A method send" do -> { m(1, 2, *x) }.should raise_error(TypeError) end end + + context "with a block argument" do + before :all do + def m(x) + if block_given? + [true, yield(x + 'b')] + else + [false] + end + end + end + + it "that refers to a proc passes the proc as the block" do + m('a', &-> y { y + 'c'}).should == [true, 'abc'] + end + + it "that is nil passes no block" do + m('a', &nil).should == [false] + end + end end describe "An element assignment method send" do |