require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper") describe "indentation" do it "can detect newliney tags" do widget = ::Erector::Widget.new widget.instance_eval do @prettyprint = true end widget.newliney("i").should == false widget.newliney("table").should == true end it "should not add newline for non-newliney tags" do Erector::Widget.new() do text "Hello, " b "World" end.to_pretty.should == "Hello, World" end it "should add newlines before open newliney tags" do Erector::Widget.new() do p "foo" p "bar" end.to_pretty.should == "
foo
\nbar
\n" end it "should add newlines between text and open newliney tag" do Erector::Widget.new() do text "One" p "Two" end.to_pretty.should == "One\nTwo
\n" end it "should add newlines after end newliney tags" do Erector::Widget.new() do tr do td "cell" end end.to_pretty.should == "before
\nafter
\n" end it "empty elements sets at_start_of_line" do Erector::Widget.new() do text "before" br p "after" end.to_pretty.should == "before\nafter
\n" end it "will not insert extra space before/after input element" do # If dim memory serves, the reason for not adding spaces here is # because it affects/affected the rendering in browsers. Erector::Widget.new() do text 'Name' input :type => 'text' text 'after' end.to_pretty.should == 'Nameafter' end it "will indent" do Erector::Widget.new() do html do head do title "hi" end body do div do p "paragraph" end end end end.to_pretty.should == <paragraph