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

\n hello world\n

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

\n....hello world\n

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