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 hello world\n
\n\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