Class: TestHtmlParser

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
test/test_util/html_parser.rb

Defined Under Namespace

Classes: StubFormatter

Instance Method Summary (collapse)

Instance Method Details

- (Object) setup



44
45
46
47
# File 'test/test_util/html_parser.rb', line 44

def setup
  @formatter = StubFormatter.new
  @parser = ODDB::HtmlParser.new(@formatter)
end

- (Object) test_end_font



109
110
111
112
113
# File 'test/test_util/html_parser.rb', line 109

def test_end_font
  html = '<font face="symbol">foo</font>'
  @parser.feed(html)
  assert_equal(:pop_fonthandler, @formatter.called)
end


69
70
71
72
73
# File 'test/test_util/html_parser.rb', line 69

def test_end_link
  html = '<a>foo</a>'
  @parser.feed(html)
  assert_equal(:pop_link, @formatter.called)
end

- (Object) test_end_table



79
80
81
82
83
# File 'test/test_util/html_parser.rb', line 79

def test_end_table
  html = '<table>foo</table>'
  @parser.feed(html)
  assert_equal(:pop_table, @formatter.called)
end

- (Object) test_end_td



99
100
101
102
103
# File 'test/test_util/html_parser.rb', line 99

def test_end_td
  html = '<td>foo</td>'
  @parser.feed(html)
  assert_equal(:pop_tablecell, @formatter.called)
end

- (Object) test_end_tr



89
90
91
92
93
# File 'test/test_util/html_parser.rb', line 89

def test_end_tr
  html = '<tr>foo</tr>'
  @parser.feed(html)
  assert_equal(:pop_tablerow, @formatter.called)
end

- (Object) test_no_premature_pre_end



58
59
60
61
62
63
# File 'test/test_util/html_parser.rb', line 58

def test_no_premature_pre_end
  html = '<b>foo<pre></b>bar</pre>baz'
  @parser.feed(html)
  assert_equal('foobaz', @formatter.flowing_data)
  assert_equal('bar', @formatter.literal_data)
end

- (Object) test_start_font



104
105
106
107
108
# File 'test/test_util/html_parser.rb', line 104

def test_start_font
  html = '<font face="symbol">'
  @parser.feed(html)
  assert_equal(:push_fonthandler, @formatter.called)
end


64
65
66
67
68
# File 'test/test_util/html_parser.rb', line 64

def test_start_link
  html = '<a>'
  @parser.feed(html)
  assert_equal(:push_link, @formatter.called)
end

- (Object) test_start_table



74
75
76
77
78
# File 'test/test_util/html_parser.rb', line 74

def test_start_table
  html = '<table>'
  @parser.feed(html)
  assert_equal(:push_table, @formatter.called)
end

- (Object) test_start_td



94
95
96
97
98
# File 'test/test_util/html_parser.rb', line 94

def test_start_td
  html = '<td>'
  @parser.feed(html)
  assert_equal(:push_tablecell, @formatter.called)
end

- (Object) test_start_tr



84
85
86
87
88
# File 'test/test_util/html_parser.rb', line 84

def test_start_tr
  html = '<tr>'
  @parser.feed(html)
  assert_equal(:push_tablerow, @formatter.called)
end

- (Object) test_unknown_entityref



48
49
50
51
52
53
54
55
56
57
# File 'test/test_util/html_parser.rb', line 48

def test_unknown_entityref
  @parser.unknown_entityref('uuml')
  assert_equal('ü', @formatter.flowing_data)
  @parser.unknown_entityref('sup2')
  assert_equal('ü²', @formatter.flowing_data)
  @parser.unknown_entityref('para')
  assert_equal('ü²¶', @formatter.flowing_data)
  @parser.unknown_entityref('ETH')
  assert_equal('ü²¶Ð', @formatter.flowing_data)
end