diff options
| -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 | 
