diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/node_spec.rb | 19 | ||||
-rw-r--r-- | spec/spec_helper.rb | 24 |
2 files changed, 22 insertions, 21 deletions
diff --git a/spec/node_spec.rb b/spec/node_spec.rb index 72230bc..98e7f99 100644 --- a/spec/node_spec.rb +++ b/spec/node_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' # def clean_static_path - static_base_path = Zorglub::Config.static_base_path + static_base_path = Node0.app.static_base_path Dir.glob( File.join(static_base_path,'**','*') ).each do |f| File.unlink f if File.file? f end Dir.glob( File.join(static_base_path,'*') ).each do |d| Dir.rmdir d end Dir.rmdir static_base_path if File.directory? static_base_path @@ -22,12 +22,11 @@ describe Zorglub do end # it "engine should return default Node's engine" do - Node0.engine.should == Zorglub::Config.engine - Node0.engine.should == Zorglub::Config[:engine] + Node0.engine.should == Node0.app.opt(:engine) end # it "layout should return default Node's layout" do - Node0.layout.should == Zorglub::Config.layout + Node0.layout.should == Node0.app.opt(:layout) end # it "engine should return class defined Node's engine" do @@ -85,8 +84,8 @@ describe Zorglub do r = Node0.my_call '/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' + ly = File.join Node0.app.layout_base_path, Node0.layout + vu = File.join Node0.app.view_base_path, Node0.r, 'index' h[:path].should == ly h[:layout].should == ly h[:view].should == vu @@ -96,8 +95,8 @@ describe Zorglub do r = Node1.my_call '/index' r.status.should == 200 h = YAML.load r.body[0] - ly = File.join Zorglub::Config.root, Zorglub::Config.layout_dir, 'main.spec' - vu = File.join Zorglub::Config.root, Zorglub::Config.view_dir, Node1.r, 'index.spec' + ly = File.join Node1.app.layout_base_path, 'main.spec' + vu = File.join Node1.app.view_base_path, Node1.r, 'index.spec' h[:path].should == ly h[:layout].should == ly h[:view].should == vu @@ -236,13 +235,13 @@ describe Zorglub do it "view_base_path! should work" do r = Node7.my_call '/view_path' h = YAML.load r.body[0] - h[:view].should == File.join(Zorglub::Config.root, 'alt','do_render') + h[:view].should == File.join(Node7.app.opt(:root), 'alt','do_render') end # it "layout_base_path! should work" do r = Node7.my_call '/view_path' h = YAML.load r.body[0] - h[:layout].should == File.join(Zorglub::Config.root, 'alt','layout','default') + h[:layout].should == File.join(Node7.app.opt(:root), 'alt','layout','default') end # end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 78ce08f..660bd39 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -28,14 +28,7 @@ RENDER_PROC = Proc.new { |path,obj| 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.register_engine 'static', nil, STATIC_PROC -# -Zorglub::Config[:engine] = 'default' -Zorglub::Config.root = File.join Dir.pwd, 'spec', 'data' +APP_ROOT = File.join Dir.pwd, 'spec', 'data' # class Zorglub::Node def self.my_call uri @@ -169,15 +162,23 @@ class Node6 < Zorglub::Node end # class Node7 < Zorglub::Node - layout_base_path! File.join Zorglub::Config.root, 'alt','layout' - view_base_path! File.join Zorglub::Config.root, 'alt' + layout_base_path! File.join APP_ROOT, 'alt','layout' + view_base_path! File.join APP_ROOT, 'alt' def view_path view! 'do_render' end end - # APP = Zorglub::App.new do + register_engine! :file, nil, Zorglub::Engines::File.method(:proc) + register_engine! :haml, 'haml', Zorglub::Engines::Haml.method(:proc) + register_engine! 'default', nil, HASH_PROC + register_engine! 'engine-1', 'spec', HASH_PROC + register_engine! 'engine-2', 'spec', HASH_PROC + register_engine! 'real', nil, RENDER_PROC + register_engine! 'static', nil, STATIC_PROC + opt! :root, APP_ROOT + opt! :engine, 'default' map '/node0', Node0 map '/node1', Node1 map '/node3', Node3 @@ -187,6 +188,7 @@ APP = Zorglub::App.new do map '/node7', Node7 map '/node8', Node8 end +# class Node2 map APP, '/node2' end |