1 describe :kernel_lambda, :shared => true do
2 it "returns a Proc object" do
3 send(@method) { true }.kind_of?(Proc).should == true
6 it "raises an ArgumentError when no block is given" do
7 lambda { send(@method) }.should raise_error(ArgumentError)
10 it "raises an ArgumentError when given too many arguments" do
12 send(@method) { |a, b| a + b }.call(1, 2, 5)
13 }.should raise_error(ArgumentError)
16 it "raises an ArgumentError when given too few arguments" do
18 send(@method) { |a, b| a + b }.call(1)
19 }.should raise_error(ArgumentError)
22 it "returns from block into caller block" do
23 # More info in the pickaxe book pg. 359
25 p = send(cmd) { return 99 }
30 # Have to pass in the @method errors otherwise
31 some_method(@method).should == "returned 99"
33 def some_method2(&b) b end
34 a_proc = send(@method) { return true }
35 res = some_method2(&a_proc)
37 res.call.should == true