File: html2haml_test.rb

package info (click to toggle)
ruby-html2haml 2.3.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 288 kB
  • sloc: ruby: 1,577; makefile: 6
file content (72 lines) | stat: -rw-r--r-- 2,518 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
class Html2HamlTest

  def test_doctype
    empty_body = "\n%html\n  %head\n  %body"
    assert_equal '!!!' + empty_body, render("<!DOCTYPE html>")
    assert_equal '!!! 1.1' + empty_body, render('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">')
    assert_equal '!!! Strict' + empty_body, render('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">')
    assert_equal '!!! Frameset' + empty_body, render('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">')
    assert_equal '!!! Mobile 1.2' + empty_body, render('<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.2//EN" "http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd">')
    assert_equal '!!! Basic 1.1' + empty_body, render('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd">')
    assert_equal '!!!' + empty_body, render('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">')
    assert_equal '!!! Strict' + empty_body, render('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">')
    assert_equal '!!! Frameset' + empty_body, render('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">')
    assert_equal '!!!' + empty_body, render('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">')
  end

  def test_xhtml_strict_doctype
    assert_equal(<<HAML.rstrip, render(<<HTML))
!!! Strict
%html
  %head
  %body
HAML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
HTML
  end

  def test_html_document_without_doctype
    assert_equal(<<HAML.rstrip, render(<<HTML))
%html
  %head
    %title Hello
  %body
    %p Hello
HAML
<html>
<head>
  <title>Hello</title>
</head>
<body>
  <p>Hello</p>
</body>
</html>
HTML
  end

  def test_should_have_attributes_without_values
    assert_equal('%input{:disabled => ""}/', render('<input disabled>'))
  end

  def test_style_to_css_filter_with_following_content
    assert_equal(<<HAML.rstrip, render(<<HTML))
%head
  :css
    foo {
        bar: baz;
    }
%body
  Hello
HAML
<head>
  <style type="text/css">
      foo {
          bar: baz;
      }
  </style>
</head>
<body>Hello</body>
HTML
  end
end