require File.join(File.dirname(__FILE__), "..", "lib", "staticmatic") describe StaticMatic::Base do before :all do @sample_site_path = File.dirname(__FILE__) + "/fixtures/sample" @staticmatic = StaticMatic::Base.new(@sample_site_path) end it "should list static pages" do @staticmatic.static_pages.should include("pages/static.html") end # Depending on system gems, markdown/textile files would be listed here too it "should list dynamic pages" do ["pages/haml_test.html.haml", "pages/hello_world.html.erb", "pages/index.html.erb", "pages/no_layout.html.erb", "pages/page_with_error.html.haml", "pages/services/index.html.erb", "pages/services/web_development.html.erb", "pages/specify_layout.html.erb"].each do |path| @staticmatic.dynamic_pages.should include(path) end end it "should list layouts" do @staticmatic.layouts.should == %w(site.html.erb specified_layout.html.erb) end it "should catch any haml template errors" do output = @staticmatic.render("page_with_error") output.should include("Illegal nesting") end it "should still render correctly after a haml error occured" do output = @staticmatic.render("page_with_error") @staticmatic.render("hello_world").should include("Hello world!") end it "should load custom helpers" do @staticmatic.template("haml_test").view.respond_to?(:say).should be_true end it "should determine template directory for file" do @staticmatic.template("stylesheets/site.css").path.should_not include("pages/") @staticmatic.template("hello_world.html").path.should include("pages/") @staticmatic.template("haml_test").path.should include("pages/") end it "should know if we can render a template or not" do @staticmatic.can_render?("hello_world.html").should_not be_false @staticmatic.can_render?("stylesheets/site.css").should_not be_false end it "should add index if needed" do @staticmatic.template("services").path.should == "pages/services/index" end end