Change soft-fail to use the config, rather than env
[rbx.git] / spec / frozen / 1.8 / core / kernel / shared / lambda.rb
blob27b781e27b1fddd2c26cec49e56595f1b631f246
1 describe :kernel_lambda, :shared => true do
2   it "returns a Proc object" do
3     send(@method) { true }.kind_of?(Proc).should == true
4   end
6   it "raises an ArgumentError when no block is given" do
7     lambda { send(@method) }.should raise_error(ArgumentError)
8   end
10   it "raises an ArgumentError when given too many arguments" do
11     lambda {
12       send(@method) { |a, b| a + b }.call(1, 2, 5)
13     }.should raise_error(ArgumentError)
14   end
16   it "raises an ArgumentError when given too few arguments" do
17     lambda {
18       send(@method) { |a, b| a + b }.call(1)
19     }.should raise_error(ArgumentError)
20   end
22   it "returns from block into caller block" do
23     # More info in the pickaxe book pg. 359
24     def some_method(cmd)
25       p = send(cmd) { return 99 }
26       res = p.call
27       "returned #{res}"
28     end
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
38   end
39 end