Sha256: f072a9461dbf81e8579220fec5972445c4aad53a1149893d6df3ff2b95841431
Contents?: true
Size: 1.03 KB
Versions: 3
Compression:
Stored size: 1.03 KB
Contents
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
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
opal-0.3.2 | gems/core/spec/language/block_spec.rb |
opal-0.3.1 | gems/core/spec/language/block_spec.rb |
opal-0.3.0 | gems/core/spec/language/block_spec.rb |