diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2012-01-03 22:32:20 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2012-01-03 22:32:20 +0100 |
commit | 0ea8b5b51b5825e7c69c3b0ed1f987166de6b598 (patch) | |
tree | 1c018b00c8fe2d2c61498a089891a933a1736acd /spec | |
parent | 0464c6ec58614e428a595d8fc1c79641774afd4c (diff) | |
download | zorglub-0ea8b5b51b5825e7c69c3b0ed1f987166de6b598.zip zorglub-0ea8b5b51b5825e7c69c3b0ed1f987166de6b598.tar.gz |
spec: add before_all and after_all specs
Diffstat (limited to 'spec')
-rw-r--r-- | spec/node_spec.rb | 23 | ||||
-rw-r--r-- | spec/spec_helper.rb | 13 |
2 files changed, 33 insertions, 3 deletions
diff --git a/spec/node_spec.rb b/spec/node_spec.rb index 84eb013..fad2a45 100644 --- a/spec/node_spec.rb +++ b/spec/node_spec.rb @@ -82,6 +82,29 @@ describe Zorglub do h[:view].should == vu end # + it "before_all hook should work" do + Node1.before = 0 + Node1.after = 0 + Node1.before.should == 0 + Node1.call( {'PATH_INFO'=>'/index'} ) + Node1.before.should == 1 + Node1.call( {'PATH_INFO'=>'/index'} ) + Node1.before.should == 2 + Node1.call( {'PATH_INFO'=>'/index'} ) + Node1.before.should == 3 + end + # + it "after_all hook should work" do + Node1.before = 0 + Node1.after = 0 + Node1.after.should == 0 + Node1.call( {'PATH_INFO'=>'/index'} ) + Node1.after.should == 1 + Node1.call( {'PATH_INFO'=>'/index'} ) + Node1.after.should == 2 + Node1.call( {'PATH_INFO'=>'/index'} ) + Node1.after.should == 3 + end end # end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index f5145f1..6dc4275 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -37,15 +37,22 @@ class Node0 < Zorglub::Node end # class Node1 < Zorglub::Node - @count=0 + @before=0 + @after=0 class << self - attr_accessor :count + attr_accessor :before, :after end before_all do |node| - Node1.count +=1 + Node1.before +=1 + end + after_all do |node| + Node1.after +=1 end layout 'spec-layout-1' engine 'spec-engine-1' + def index + (self.class.before-self.class.after).should == 1 + end end # class Node2 < Zorglub::Node |