scope "Hypertext" do test "text" do expected = "hello world\n" ht = Hypertext.new ht.text "hello world" assert_equal expected, ht.to_s end test "self-closing tags" do expected = "
\n" ht = Hypertext.new ht.tag :br assert_equal expected, ht.to_s end test "opening and closing tags" do expected = "\n hello world\n\n" ht = Hypertext.new ht.tag :span do ht.text "hello world" end assert_equal expected, ht.to_s end test "nested tags" do expected = "
\n

\n hello world\n

\n
\n" ht = Hypertext.new ht.tag :div do ht.tag :p do ht.text "hello world" end end assert_equal expected, ht.to_s end test "passing a block to Hypertext.new" do expected = "
\n" ht = Hypertext.new do |ht| ht.tag :br end assert_equal expected, ht.to_s end test "tags with attributes" do expected = "\n" ht = Hypertext.new do |ht| ht.tag :input, :type => "text", :name => "person[name]", :value => "Foo" end assert_equal expected, ht.to_s end test "custom indentation" do expected = "

\n....hello world\n

\n" ht = Hypertext.new do |ht| ht.tag :p do ht.text "hello world" end end assert_equal expected, ht.to_s("....") end end