diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2012-01-03 22:17:29 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2012-01-03 22:17:29 +0100 |
commit | 5123b14118b46424e7ed0df9af6bf4ca21a4284d (patch) | |
tree | 4de1b5d8f69b494a2e2daa8d02b1c6702112af52 | |
parent | 4c14c7c4c57f20451cd92512f07978e3b1c64885 (diff) | |
download | zorglub-5123b14118b46424e7ed0df9af6bf4ca21a4284d.zip zorglub-5123b14118b46424e7ed0df9af6bf4ca21a4284d.tar.gz |
spec: add arguments specs
-rw-r--r-- | spec/node_spec.rb | 11 | ||||
-rw-r--r-- | spec/spec_helper.rb | 4 |
2 files changed, 14 insertions, 1 deletions
diff --git a/spec/node_spec.rb b/spec/node_spec.rb index 06b7fd1..e2372b8 100644 --- a/spec/node_spec.rb +++ b/spec/node_spec.rb @@ -49,6 +49,17 @@ describe Zorglub do r.body[0].should == 'world' end # + it "arguments should work" do + r = Node0.call( {'PATH_INFO'=>'/with_2args/1/2'} ) + h = YAML.load r.body[0] + h[:args][0].should == '1' + h[:args][1].should == '2' + end + # + it "should raise error when too much arguments" do + lambda{ r = Node0.call( {'PATH_INFO'=>'/with_2args/1/2/3'} ) }.should raise_error ArgumentError + end + # it "layout proc, method level layout and engine definitions should work" do r = Node0.call( {'PATH_INFO'=>'/index'} ) r.status.should == 200 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 907a84d..a54aa6f 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -12,7 +12,7 @@ require 'yaml' # require 'zorglub' # -ENGINE_PROC = Proc.new { |path,obj| {:path=>path,:layout=>obj.layout,:view=>obj.view}.to_yaml } +ENGINE_PROC = Proc.new { |path,obj| {:path=>path,:layout=>obj.layout,:view=>obj.view,:args=>obj.args}.to_yaml } Zorglub::Config.register_engine 'default', nil, ENGINE_PROC Zorglub::Config.register_engine 'spec-engine-1', 'spec', ENGINE_PROC Zorglub::Config.register_engine 'spec-engine-2', 'spec', ENGINE_PROC @@ -31,6 +31,8 @@ class Node0 < Zorglub::Node layout 'none' 'world' end + def with_2args a1, a2 + end end # class Node1 < Zorglub::Node |