From c2c4286fa16e726d227b678fb18d30f1cbb93612 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Tue, 3 Jan 2012 17:08:32 +0100 Subject: node_spec: set proc layout and default layout view spec --- spec/data/layout/default | 0 spec/node_spec.rb | 11 +++++++++++ spec/spec_helper.rb | 11 +++++++++-- 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 spec/data/layout/default diff --git a/spec/data/layout/default b/spec/data/layout/default new file mode 100644 index 0000000..e69de29 diff --git a/spec/node_spec.rb b/spec/node_spec.rb index 845cc11..74eb5e9 100644 --- a/spec/node_spec.rb +++ b/spec/node_spec.rb @@ -48,6 +48,17 @@ describe Zorglub do r.body[0].should == 'world' end # + it "layout proc, method level layout and engine definitions should work" do + r = Node0.call( {'PATH_INFO'=>'/index'} ) + r.status.should == 200 + h = YAML.load r.body[0] + ly = File.join Zorglub::Config.root, Zorglub::Config.layout_dir, Node0.layout + vu = File.join Zorglub::Config.root, Zorglub::Config.view_dir, Node0.r, 'index' + h['path'].should == ly + h['layout'].should == ly + h['view'].should == vu + end + # end # end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 3ca9523..1ada235 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -8,20 +8,27 @@ begin rescue LoadError end # +require 'yaml' +# require 'zorglub' # -ENGINE_PROC = Proc.new { |path,obj| "path=>#{path} : obj=>#{obj}" } +ENGINE_PROC = Proc.new { |path,obj| {'path'=>path,'layout'=>obj.layout,'view'=>obj.view}.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 # -Zorglub::Config.engine = 'haml' +Zorglub::Config.engine = 'default' +Zorglub::Config.root = File.join Dir.pwd, 'spec', 'data' # class Temp < Zorglub::Node end # class Node0 < Zorglub::Node # default + def index + end def hello + layout 'none' 'world' end end -- cgit v1.1-2-g2b99