summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2012-01-03 23:16:36 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2012-01-03 23:16:36 +0100
commitdba8a2aad7ae72c73e5629b49e782e235eb404b6 (patch)
tree052ff919f0fd9bfaf02ce10cb238d7eeaf644890 /spec
parent069ab960ad7afcfbcabc35dcaa904c5940ee1b5c (diff)
downloadzorglub-dba8a2aad7ae72c73e5629b49e782e235eb404b6.zip
zorglub-dba8a2aad7ae72c73e5629b49e782e235eb404b6.tar.gz
spec: add view and layout rendering spec
Diffstat (limited to 'spec')
-rw-r--r--spec/data/view/node0/do_render0
-rw-r--r--spec/node_spec.rb7
-rw-r--r--spec/spec_helper.rb15
3 files changed, 22 insertions, 0 deletions
diff --git a/spec/data/view/node0/do_render b/spec/data/view/node0/do_render
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/spec/data/view/node0/do_render
diff --git a/spec/node_spec.rb b/spec/node_spec.rb
index 40ea901..cc665b7 100644
--- a/spec/node_spec.rb
+++ b/spec/node_spec.rb
@@ -105,6 +105,13 @@ describe Zorglub do
Node3.call( {'PATH_INFO'=>'/index'} )
Node3.after.should == 3
end
+ #
+ it "should find view and layout and render them" do
+ r = Node0.call( {'PATH_INFO'=>'/do_render'} )
+ r.status.should == 200
+ r.body[0].should == "layout_start view_content layout_end"
+ end
+ #
end
#
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index aa096e7..5763a8c 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -13,9 +13,21 @@ require 'yaml'
require 'zorglub'
#
HASH_PROC = Proc.new { |path,obj| {:path=>path,:layout=>obj.layout,:view=>obj.view,:args=>obj.args}.to_yaml }
+RENDER_PROC = Proc.new { |path,obj|
+ m = obj.action[:mode]
+ case m
+ when :layout
+ "layout_start #{obj.content} layout_end"
+ when :view
+ "view_content"
+ else
+ raise Exception.new
+ end
+}
Zorglub::Config.register_engine 'default', nil, HASH_PROC
Zorglub::Config.register_engine 'engine-1', 'spec', HASH_PROC
Zorglub::Config.register_engine 'engine-2', 'spec', HASH_PROC
+Zorglub::Config.register_engine 'real', nil, RENDER_PROC
#
Zorglub::Config[:engine] = 'default'
Zorglub::Config.root = File.join Dir.pwd, 'spec', 'data'
@@ -34,6 +46,9 @@ class Node0 < Zorglub::Node
end
def with_2args a1, a2
end
+ def do_render
+ engine 'real'
+ end
end
#
class Node1 < Zorglub::Node