class TestHTreeWabisabi

Public Instance Methods

ok(e, xml) click to toggle source
# File vendor/qwik/lib/qwik/wabisabi-to-htree.rb, line 67
def ok(e, xml)
  ok_eq(e, generate(xml).format_xml(0))
end
ok_in(e, s) click to toggle source
# File vendor/qwik/lib/qwik/wabisabi-to-htree.rb, line 71
def ok_in(e, s)
  ok_eq(e, s.format_xml)
end
test_all() click to toggle source
# File vendor/qwik/lib/qwik/wabisabi-to-htree.rb, line 75
def test_all
  ok("<a\n/>", [:a])
  ok("<a href=\"foo.html\"\n/>", [:a, {:href=>"foo.html"}])
  ok("<a\n><b\n/></a\n>", [:a, [:b]])
  ok("<html\n><body\n><p\n><a href=\"foo.html\"\n>foo</a\n></p\n></body\n></html\n>", [:html, [:body, [:p, [:a, {:href => "foo.html"}, 'foo']]]])
  @g = HTree::Generator.new
  ok("<a\n><b\n/></a\n>", [:a, @g.b])

  # test_multi_attr
  ok("<a href=\"foo.html\"\n/>", [:a, {:href=>"foo.html"}])
  ok("<a href=\"foo.html\" class=\"bar\"\n/>",
     [:a, {:href=>'foo.html', :class=>'bar'}])
  ok("<a href=\"foo.html\" class=\"bar\"\n/>",
     [:a, {:href=>'foo.html'}, {:class=>'bar'}])

  # test_to_htree
  g = HTree::WabisabiGenerator.new
  ok_in("<a/>", g.to_htree([:a]))
  ok_in("<a/>", HTree::WabisabiGenerator.new.to_htree([:a]))
end