Sha256: c63c92c8374b670f5d0e463fb59ec67682f5cc2c973fa8b5ec059b27bea0b8e4
Contents?: true
Size: 1.82 KB
Versions: 1
Compression:
Stored size: 1.82 KB
Contents
scope "Hypertext" do test "append" do expected = "hello → world\n" ht = Hypertext.new ht.append "hello → world" assert_equal expected, ht.to_s end 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 = "<br />\n" ht = Hypertext.new ht.tag :br assert_equal expected, ht.to_s end test "opening and closing tags" do expected = "<span>\n hello world\n</span>\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 = "<div>\n <p>\n hello world\n </p>\n</div>\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 = "<br />\n" ht = Hypertext.new do |ht| ht.tag :br end assert_equal expected, ht.to_s end test "tags with attributes" do expected = "<input type=\"text\" name=\"person[name]\" value=\"Foo\" />\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 = "<p>\n....hello world\n</p>\n" ht = Hypertext.new do |ht| ht.tag :p do ht.text "hello world" end end assert_equal expected, ht.to_s("....") end end scope "Hypertext::DSL" do test do expected = "<head>\n <title>\n hello world\n </title>\n</head>\n" ht = Hypertext::DSL.new do head do title do text "hello world" end end end assert_equal expected, ht.to_s end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hypertext-0.0.4 | test/all.rb |