/index.haml
# encoding: UTF-8 require "spec_helper" require "rack/test" describe Mango::Application do include Rack::Test::Methods def app Mango::Application end ################################################################################################# describe "GET (empty String)" do before(:all) do get "" end it "returns 200 status code" do last_response.should be_ok end it "sends the correct Content-Type header" do last_response["Content-Type"].should == "text/html;charset=utf-8" end it "sends the correct body content" do last_response.body.should == <<-EXPECTED
page.haml
/index.haml
page.haml
/index.haml
page.haml
/index.haml
page.haml
/index.haml
page.haml
/about/index.haml
page.haml
/about/index.haml
page.haml
/about/us.haml
page.haml
/turner+hooch.haml
page.erb
/view_engines/erb.haml
page.liquid
/view_engines/liquid.haml
404.html
EXPECTED end end ################################################################################################# describe "GET /page_with_unregistered_view" do it "raises an exception" do path = FIXTURE_ROOT + "themes/default/views/unregistered.extension" message = "Cannot find registered engine for view template file -- #{path}" lambda { get "/page_with_unregistered_view" }.should raise_exception(Mango::Application::RegisteredEngineNotFound, message) end end ################################################################################################# describe "GET /page_with_missing_view" do it "raises an exception" do path = FIXTURE_ROOT + "themes/default/views/missing.haml" message = "Cannot find view template file -- #{path}" lambda { get "/page_with_missing_view" }.should raise_exception(Mango::Application::ViewTemplateNotFound, message) end end ################################################################################################# describe "GET /../security_hole" do before(:all) do get "/../security_hole" end it "returns 404 status code" do last_response.should be_not_found end it "sends the correct Content-Type header" do last_response["Content-Type"].should == "text/html;charset=utf-8" end it "sends the correct body content" do last_response.body.should == <<-EXPECTED404.html
EXPECTED end end ################################################################################################# describe "GET /engines/haml" do before(:all) do get "/engines/haml" end it "returns 200 status code" do last_response.should be_ok end it "sends the correct Content-Type header" do last_response["Content-Type"].should == "text/html;charset=utf-8" end it "sends the correct body content" do last_response.body.should == <<-EXPECTEDpage.haml
engines haml
/engines/haml.haml
page.haml
page.haml
page.haml
engines erb
/engines/erb.erb
page.haml
engines liquid
/engines/liquid.liquid