summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2012-01-05 12:23:39 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2012-01-05 12:23:39 +0100
commitfc3f593b5357849891b00a453e9d778560c6049e (patch)
tree10e169564288bfed5731e839468b3790c293e7d0
parent0827f783531b318af55a1048ad69ee4c112e0873 (diff)
downloadzorglub-fc3f593b5357849891b00a453e9d778560c6049e.zip
zorglub-fc3f593b5357849891b00a453e9d778560c6049e.tar.gz
spec: add specs for static pages generation
-rw-r--r--spec/node_spec.rb15
-rw-r--r--spec/spec_helper.rb21
2 files changed, 36 insertions, 0 deletions
diff --git a/spec/node_spec.rb b/spec/node_spec.rb
index f78eb64..0a9ee10 100644
--- a/spec/node_spec.rb
+++ b/spec/node_spec.rb
@@ -136,6 +136,21 @@ describe Zorglub do
Node0.partial(:other_view).should == 'partial_content'
end
#
+ it "static pages should be generated" do
+ r = Node0.my_call '/do_static'
+ r.body[0].should == 'VAL 1'
+ r.header['Content-type'].should == 'text/static'
+ r = Node0.my_call '/do_static'
+ r.body[0].should == 'VAL 1'
+ r.header['Content-type'].should == 'text/static'
+ r = Node0.my_call '/do_static'
+ r.body[0].should == 'VAL 1'
+ r.header['Content-type'].should == 'text/static'
+ r = Node0.my_call '/no_static'
+ r.body[0].should == 'VAL 4'
+ r.header['Content-type'].should == 'text/static'
+ end
+ #
it "redirect should work" do
r = Node0.my_call '/do_redirect'
r.status.should == 302
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index c379361..c1e6d64 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -13,6 +13,7 @@ require 'yaml'
require 'zorglub'
#
HASH_PROC = Proc.new { |path,obj| {:path=>path,:layout=>obj.layout,:view=>obj.view,:args=>obj.args,:map=>obj.map}.to_yaml }
+STATIC_PROC = Proc.new { |path,obj| ["VAL #{obj.value}",'text/static'] }
RENDER_PROC = Proc.new { |path,obj|
case obj.state
when :layout
@@ -29,6 +30,7 @@ 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'
@@ -43,6 +45,10 @@ class Temp < Zorglub::Node
end
#
class Node0 < Zorglub::Node
+ @static_cpt=0
+ class << self
+ attr_accessor :static_cpt
+ end
# default
def index
html
@@ -66,6 +72,21 @@ class Node0 < Zorglub::Node
def do_redirect
redirect r(:do_partial,1,2,3)
end
+ attr_reader :value
+ def no_static
+ static false
+ engine 'static'
+ view r('do_render')
+ Node0.static_cpt+=1
+ @value = Node0.static_cpt
+ end
+ def do_static
+ static true
+ engine 'static'
+ view r('do_render')
+ Node0.static_cpt+=1
+ @value = Node0.static_cpt
+ end
end
#
class Node1 < Zorglub::Node