Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: a59ff81acd
Fetching contributors…

Cannot retrieve contributors at this time

39 lines (33 sloc) 1.081 kb
require File.dirname(__FILE__) + '/../spec_helper'
require File.dirname(__FILE__) + '/fixtures/block'
describe "A block with a 'rest' arg" do
it "collects all of the arguments passed to yield" do
ret = nil
BlockSpecs::Yield.new.splat(1,2,3) {|*args| ret = args}
ret.should == [1,2,3]
end
end
describe "A block with an anonymous 'rest' arg" do
it "ignores all of the arguments passed to yield" do
ret = [1].each {|*| }
ret.should == [1]
end
end
describe "A block whose arguments are splatted" do
it "captures the arguments passed to the block in an array" do
a = []
BlockSpecs::Yield.new.two_args { |*args| a << args }
a.should == [[1, 2]]
end
it "captures the array passed to the block in an array" do
a = []
BlockSpecs::Yield.new.two_arg_array { |*args| a << args }
a.should == [[[1, 2]]]
end
it "yields the correct arguments in a nested block" do
a = []
BlockSpecs::Yield.new.yield_splat_inside_block {|a1, a2| a << [a1, a2]}
a.should == [[1, 0], [2, 1]]
end
end
language_version __FILE__, "block"
Jump to Line
Something went wrong with that request. Please try again.