spec/bonsai/page_spec.rb in bonsai-1.3.1 vs spec/bonsai/page_spec.rb in bonsai-1.3.2
- old
+ new
@@ -63,57 +63,16 @@
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"
+ @page.assets.first[:disk_path].should == File.join(Dir.pwd, "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
@@ -194,11 +153,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/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"
+ @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 not when there is nothing left to add, but when there is nothing left to take away.”</p>\n\n<p>– Antoine de Saint-Exupery</p>"
end
it "should write in images" do
@output.should include "image001.jpg"
end
@@ -214,15 +173,15 @@
it "should not use markdown for single line content" do
@output.should =~ /\nGet in touch\n/
end
it "should use markdown for multiple line content" do
- @output.should =~ /<p>“A designer knows he/
+ @output.should =~ /<p>“A designer knows he/
end
it "should use smartypants" do
- @output.should =~ /”/
+ @output.should =~ /“/
end
end
end
describe "to hash" do
@@ -242,9 +201,31 @@
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