# 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 layout.haml

Welcome to Mango!

page.haml

/index.haml

EXPECTED end end ################################################################################################# describe "GET /" 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 layout.haml

Welcome to Mango!

page.haml

/index.haml

EXPECTED end end ################################################################################################# describe "GET /index" do before(:all) do get "/index" 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 layout.haml

Welcome to Mango!

page.haml

/index.haml

EXPECTED end end ################################################################################################# describe "GET /index?foo=bar" do before(:all) do get "/index?foo=bar" 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 layout.haml

Welcome to Mango!

page.haml

/index.haml

EXPECTED end end ################################################################################################# describe "GET /about/" do before(:all) do get "/about/" 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 layout.haml

Welcome to Mango!

page.haml

/about/index.haml

EXPECTED end end ################################################################################################# describe "GET /about/index" do before(:all) do get "/about/index" 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 layout.haml

Welcome to Mango!

page.haml

/about/index.haml

EXPECTED end end ################################################################################################# describe "GET /about/us" do before(:all) do get "/about/us" 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 layout.haml

Welcome to Mango!

page.haml

/about/us.haml

EXPECTED end end ################################################################################################# describe "GET /turner%2Bhooch" do before(:all) do get "/turner%2Bhooch" 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 layout.haml

Welcome to Mango!

page.haml

/turner+hooch.haml

EXPECTED end end ################################################################################################# describe "GET /view_engines/erb" do before(:all) do get "/view_engines/erb" 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 layout.erb

Welcome to Mango!

page.erb

/view_engines/erb.haml

EXPECTED end end ################################################################################################# describe "GET /view_engines/liquid" do before(:all) do get "/view_engines/liquid" 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 layout.liquid

Welcome to Mango!

page.liquid

/view_engines/liquid.haml

EXPECTED end end ################################################################################################# describe "GET /page_not_found" do before(:all) do get "/page_not_found" 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 == <<-EXPECTED 404 Page

Page not found

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 == <<-EXPECTED 404 Page

Page not found

404.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 == <<-EXPECTED layout.haml

Welcome to Mango!

page.haml

engines haml

/engines/haml.haml

EXPECTED end end ################################################################################################# describe "GET /engines/md" do before(:all) do get "/engines/md" 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 layout.haml

Welcome to Mango!

page.haml

/engines/md.md

EXPECTED end end ################################################################################################# describe "GET /engines/mkd" do before(:all) do get "/engines/mkd" 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 layout.haml

Welcome to Mango!

page.haml

/engines/mkd.mkd

EXPECTED end end ################################################################################################# describe "GET /engines/erb" do before(:all) do get "/engines/erb" 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 layout.haml

Welcome to Mango!

page.haml

engines erb

/engines/erb.erb

EXPECTED end end ################################################################################################# describe "GET /engines/liquid" do before(:all) do get "/engines/liquid" 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 layout.haml

Welcome to Mango!

page.haml

engines liquid

/engines/liquid.liquid

EXPECTED end end end