0
@@ -9,39 +9,60 @@ describe "Page Caching" do
0
describe "use_page_caching is turned on" do
0
it "should serve a cached page" do
0
- temp_app_config(:use_page_caching => true) do
0
- Cachetastic::Caches::PageCache.set("/", Mack::Caching::PageCaching::Page.new("hello"))
0
- response.body.should == "hello"
0
+ Cachetastic::Caches::PageCache.set("/", Mack::Caching::PageCaching::Page.new("hello"))
0
+ response.body.should == "hello"
0
+ response.content_type.should == "text/html"
0
it "should cache a page designated to be cached" do
0
- temp_app_config(:use_page_caching => true) do
0
- response.body.should match(/Welcome to your Mack application!/)
0
- Cachetastic::Caches::PageCache.get("/").to_s.should == response.body
0
+ get "/default/hello_world?name=mark"
0
+ response.body.should match(/<p>mark<\/p>/)
0
+ page = Cachetastic::Caches::PageCache.get("/default/hello_world?name=mark")
0
+ page.to_s.should == response.body
0
+ page.content_type.should == "text/html"
0
- it "should store the content type correctly"
0
+ it "should store and deliver the content type correctly" do
0
+ get "/default/hello_world.xml?name=mark"
0
+ response.body.should match(/<name>mark<\/name>/)
0
+ response.content_type.should == "application/xml; text/xml"
0
+ old_body = response.body
0
+ get "/default/hello_world.xml?name=mark"
0
+ response.body.should == old_body
0
+ response.content_type.should == "application/xml; text/xml"
0
- it "should deliver the content type correctly"
0
- it "should store the status correctly"
0
+ it "should never store non-successful pages" do
0
+ get "/default/always_500"
0
+ response.status.should == 500
0
+ Cachetastic::Caches::PageCache.get("/default/always_500").should be_nil
0
- it "should deliver the status correctly"
0
describe "use_page_caching is turned off" do
0
it "should serve the uncached page" do
0
- response.body.should match(/Welcome to your Mack application!/)
0
+ temp_app_config("use_page_caching" => false) do
0
+ get "/default/hello_world?name=mark"
0
+ response.body.should match(/<p>mark<\/p>/)
0
+ old_body = response.body
0
+ get "/default/hello_world?name=mark"
0
+ response.body.should match(/<p>mark<\/p>/)
0
+ response.body.should_not == old_body
0
- it "should not store the cached page"
0
+ it "should not store the cached page" do
0
+ temp_app_config("use_page_caching" => false) do
0
+ get "/default/hello_world?name=mark"
0
+ response.body.should match(/<p>mark<\/p>/)
0
+ Cachetastic::Caches::PageCache.get("/default/hello_world?name=mark").should be_nil