Added tests for parameterized blocks.

This commit is contained in:
doop 2013-04-01 07:53:44 +04:00
parent 7839870c52
commit dbc7f24043
1 changed files with 35 additions and 1 deletions

View File

@ -45,12 +45,46 @@ describe Docile do
def inner(&block)
Docile.dsl_eval(InnerDSL.new, &block)
end
def inner_with_params(param,&block)
Docile.dsl_eval(InnerDSL.new, param, :foo, &block)
end
end
def outer(&block)
Docile.dsl_eval(OuterDSL.new, &block)
end
def parameterized(*args,&block)
Docile.dsl_eval(OuterDSL.new, *args, &block)
end
context "parameters" do
it "should pass parameters to the block" do
parameterized(1,2,3) do |x,y,z|
x.should == 1
y.should == 2
z.should == 3
end
end
it "should find parameters before methods" do
parameterized(1) { |a| a.should == 1 }
end
it "should find outer parameters in inner dsl scope" do
parameterized(1,2,3) do |a,b,c|
inner_with_params(c) do |d,e|
a.should == 1
b.should == 2
c.should == 3
d.should == c
e.should == :foo
end
end
end
end
context "methods" do
it "should find method of outer dsl in outer dsl scope" do
outer { a.should == 'a' }
@ -113,4 +147,4 @@ describe Docile do
end
end
end