spec/base_spec.rb in tdreyno-staticmatic-2.1.4 vs spec/base_spec.rb in tdreyno-staticmatic-2.9.0
- old
+ new
@@ -4,10 +4,27 @@
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
@@ -15,28 +32,23 @@
output = @staticmatic.render("page_with_error")
@staticmatic.render("hello_world").should include("Hello world!")
end
it "should load custom helpers" do
- @staticmatic.view.respond_to?(:say).should be_true
+ @staticmatic.template("haml_test").view.respond_to?(:say).should be_true
end
it "should determine template directory for file" do
- @staticmatic.full_template_path("stylesheets/site.css").should_not include("pages/")
- @staticmatic.full_template_path("hello_world.html").should include("pages/")
- @staticmatic.full_template_path("haml_test").should include("pages/")
+ @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.full_template_path("services").should == "pages/services/index"
- end
-
- it "should know the relative path to the base dir" do
- @staticmatic.calculate_relative_path_to_root("pages/services/web_development/costs").should == "../../"
- @staticmatic.calculate_relative_path_to_root("pages/services/web_development").should == "../"
+ @staticmatic.template("services").path.should == "pages/services/index"
end
end
\ No newline at end of file