spec/unit/arbre/html/element_spec.rb in activeadmin-0.3.4 vs spec/unit/arbre/html/element_spec.rb in activeadmin-0.4.0

- old
+ new

@@ -71,15 +71,28 @@ context "when the child is a string" do let(:child){ "Hello World" } it "should add as a TextNode" do element.children.first.should be_instance_of(Arbre::HTML::TextNode) - element.children.first.to_html.should == "Hello World" + element.children.first.to_s.should == "Hello World" end end end + describe "#children?" do + + it "returns true when a child has been added" do + element.add_child Arbre::HTML::Element.new + element.children?.should == true + end + + it "returns false when no children" do + element.children?.should == false + end + + end + describe "setting the content" do context "when a string" do before do element.add_child "Hello World" @@ -88,17 +101,17 @@ it "should clear the existing children" do element.children.size.should == 1 end it "should add the string as a child" do - element.children.first.to_html.should == "Goodbye" + element.children.first.to_s.should == "Goodbye" end it "should html escape the string" do string = "Goodbye <br />" element.content = string - element.content.to_html.should == "Goodbye &lt;br /&gt;" + element.to_s.should == "Goodbye &lt;br /&gt;" end end context "when a tag" do before do @@ -144,11 +157,11 @@ end end describe "rendering to html" do it "should render the children collection" do - element.children.should_receive(:to_html).and_return("content") - element.to_html.should == "content" + element.children.should_receive(:to_s).and_return("content") + element.to_s.should == "content" end end describe "adding elements together" do