require File.dirname(__FILE__) + '/spec_helper.rb' require "rack" require_fixtures 'application_spec_applications' describe Trellis::Application, " a Trellis application when declared" do before do @homepage = TestApp::MyApp.instance_eval { @homepage } @pages = TestApp::MyApp.instance_eval { @pages } @static_routes = TestApp::MyApp.instance_eval { @static_routes } end it "should contain a contain the symbol for its home page" do @homepage.should == :home end it "should contain the home page in its collection of pages" do @pages.include?(:home).should be(true) end it "should contain any declared static routes" do images_route = @static_routes.select { |item| item[:urls].include?('/images') } images_route.should_not be_empty style_route = @static_routes.select { |item| item[:urls].include?('/style') } style_route.should_not be_empty favicon_route = @static_routes.select { |item| item[:urls].include?('/favicon.ico') } favicon_route.should_not be_empty yui_route = @static_routes.select { |item| item[:urls].include?('/yui') && item[:root].include?('./js') } yui_route.should_not be_empty end end describe Trellis::Application, " when requesting the root url with a GET" do before(:each) do application = TestApp::MyApp.new request = Rack::MockRequest.new(application) @response = request.get("/") end it "should return an OK HTTP status" do @response.status.should be(200) end it "should reply with the home page" do @response.body.should == "
Goodbye Cruel World
" end end describe Trellis::Page, " when calling inject_dependent_pages on an instance of child class of Page" do it "should contain instances of the injected pages" do homepage = TestApp::Home.new homepage.inject_dependent_pages injected_page = homepage.instance_eval { @other } injected_page.class.should == TestApp::Other end end