spec/bonsai/page_spec.rb in bonsai-1.3.0 vs spec/bonsai/page_spec.rb in bonsai-1.3.1
- old
+ new
@@ -35,10 +35,11 @@
it "should have an mtime" do
@page.should respond_to :mtime
@page.mtime.should be_an_instance_of(Time)
end
+
it "should remove numbers over 10 from the permalink" do
Bonsai::Page.find("many-pages").permalink.should == "/many-pages/"
end
it "should have a write_path" do
@@ -54,20 +55,65 @@
@page.assets.should be_an_instance_of(Array)
@page.assets.length.should == 6
end
it "should have the correct name" do
- @page.assets.first[:name].should == "001.jpg"
+ @page.assets.first[:name].should == "001"
end
it "should have the correct path" do
@page.assets.first[:path].should == "/about-us/history/001.jpg"
end
it "should have the correct disk_path" do
@page.assets.first[:disk_path].should == "/Users/ben/Documents/Projects/bonsai/spec/support/content/1.about-us/history/001.jpg"
end
+
+ it "should titleize the name attribute and remove the file extension" do
+ @page.assets[2][:name].should == "A File Asset"
+ end
+
+ describe "disk_assets" do
+ before :all do
+ @page = Bonsai::Page.find("about-us/contact")
+ end
+
+ it "should have magic" do
+ @page.to_hash.should have_key(:magic)
+ end
+
+ it "should have assets" do
+ @page.to_hash[:magic][:files].should be_an_instance_of(Array)
+ @page.to_hash[:magic][:files].should_not be_empty
+ end
+
+ it "it should be a an array of hashes" do
+ @page.to_hash[:magic][:files].should be_an_instance_of(Array)
+ @page.to_hash[:magic][:files].first.should be_an_instance_of(Hash)
+ @page.to_hash[:magic][:files].size.should == 2
+ end
+
+ it "should have children" do
+ @page.to_hash[:magic][:children].should_not be_empty
+ end
+
+ describe "children (pages)" do
+ it "should represent the children as pages" do
+ @page.to_hash[:magic][:children].first.should be_an_instance_of(Bonsai::Page)
+ end
+
+ it "should contain a single child" do
+ @page.to_hash[:magic][:children].size.should == 1
+ end
+
+ %w(slug permalink name page_title children siblings parent ancestors navigation updated_at created_at).each do |key|
+ it "should have a to_hash key for #{key}" do
+ @page.to_hash[:magic][:children].first.to_hash.keys.should include(key.to_sym)
+ end
+ end
+ end
+ end
end
it "should be equal" do
Bonsai::Page.find("about-us").should == Bonsai::Page.find("about-us")
end
@@ -148,11 +194,11 @@
it "should render" do
@output.should_not be_nil
end
it "should replace mustache variables with properties from the content file" do
- @output.should == "Hello from our template, named Contact\n\nGet in touch\n\n/about-us/contact/images/image001.jpg\n/about-us/contact/child/\n/about-us/contact/magic/image001.jpg\n/about-us/contact/magic/image002.jpg\nThis content should be inserted!\n\n<p>“A designer knows he has achieved perfection\nnot when there is nothing left to add,\nbut when there is nothing left to take away.”</p>\n\n<p>– Antoine de Saint-Exupery</p>\n"
+ @output.should == "Hello from our template, named Contact\n\nGet in touch\n\n/about-us/contact/images/image001.jpg\n/about-us/contact/child/\n/about-us/contact/magic/containing-a-page\n/about-us/contact/magic/image001.jpg\n/about-us/contact/magic/image002.jpg\nThis content should be inserted!\n\n<p>“A designer knows he has achieved perfection\nnot when there is nothing left to add,\nbut when there is nothing left to take away.”</p>\n\n<p>– Antoine de Saint-Exupery</p>\n"
end
it "should write in images" do
@output.should include "image001.jpg"
end
@@ -196,31 +242,9 @@
it "should include global site variables from site.yml" do
@page.to_hash[:site_name].should == "Bonsai"
@page.to_hash[:url].should == "http://tinytree.info"
@page.to_hash[:copyright].should == 2010
- end
-
- describe "disk_assets" do
- before :all do
- @vars = @page.to_hash
- end
-
- describe "enum" do
- it "should not have a child" do
- @vars.should_not have_key(:child)
- end
-
- it "should have magic" do
- @vars.should have_key(:magic)
- end
-
- it "it should be a an array of hashes" do
- @vars[:magic].should be_an_instance_of(Array)
- @vars[:magic].first.should be_an_instance_of(Hash)
- @vars[:magic].size.should == 2
- end
- end
end
end
describe "broken page" do
before :all do