From 65c77e80fc100d16c51a634639032fe43f2f2908 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Tue, 17 Jan 2012 10:13:50 +0100 Subject: add spec for inherited before_all and after_all hooks --- spec/node_spec.rb | 24 ++++++++++++++++++++++++ spec/spec_helper.rb | 6 +++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/spec/node_spec.rb b/spec/node_spec.rb index 279ec2b..72230bc 100644 --- a/spec/node_spec.rb +++ b/spec/node_spec.rb @@ -127,6 +127,30 @@ describe Zorglub do Node3.after.should == 3 end # + it "inherited before_all hook should work" do + Node3.before = 0 + Node3.after = 0 + Node3.before.should == 0 + Node8.my_call '/index' + Node3.before.should == 1 + Node8.my_call '/index' + Node3.before.should == 2 + Node8.my_call '/index' + Node3.before.should == 3 + end + # + it "inherited after_all hook should work" do + Node3.before = 0 + Node3.after = 0 + Node3.after.should == 0 + Node8.my_call '/index' + Node3.after.should == 1 + Node8.my_call '/index' + Node3.after.should == 2 + Node8.my_call '/index' + Node3.after.should == 3 + end + # it "should find view and layout and render them" do r = Node0.my_call '/do_render' r.status.should == 200 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 8c6c2bc..78ce08f 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -117,10 +117,13 @@ class Node3 < Zorglub::Node layout! 'layout-2' engine! 'engine-2' def index - (self.class.before-self.class.after).should == 1 + (Node3.before-Node3.after).should == 1 end end # +class Node8 < Node3 +end +# class Node4 < Zorglub::Node no_layout! inherited_var :js,'js0','js1' @@ -182,6 +185,7 @@ APP = Zorglub::App.new do map '/node5', Node5 map '/node6', Node6 map '/node7', Node7 + map '/node8', Node8 end class Node2 map APP, '/node2' -- cgit v1.1-2-g2b99