Class: TC_TestHTMLTokenizer
- Inherits:
-
Test::Unit::TestCase
- Object
- Test::Unit::TestCase
- TC_TestHTMLTokenizer
- Defined in:
- lib/html/htmltokenizer.rb
Instance Method Summary collapse
Instance Method Details
#test_bad_link ⇒ Object
307 308 309 310 |
# File 'lib/html/htmltokenizer.rb', line 307 def test_bad_link toke = HTMLTokenizer.new("<p><a href=http://bad.com/link>foo</a></p>") assert("http://bad.com/link" == toke.getTag("a").attr_hash['href']) end |
#test_comment ⇒ Object
317 318 319 320 321 322 |
# File 'lib/html/htmltokenizer.rb', line 317 def test_comment toke = HTMLTokenizer.new("<!-- comment on me -->") t = toke.getNextToken assert(HTMLComment == t.class) assert("comment on me" == t.contents) end |
#test_full ⇒ Object
325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 |
# File 'lib/html/htmltokenizer.rb', line 325 def test_full page = "<HTML> <HEAD> <TITLE>This is the title</TITLE> </HEAD> <!-- Here comes the <a href=\"missing.link\">blah</a> comment body --> <BODY> <H1>This is the header</H1> <P> This is the paragraph, it contains <a href=\"link.html\">links</a>, <img src=\"blah.gif\" optional alt='images are really cool'>. Ok, here is some more text and <A href=\"http://another.link.com/\" target=\"_blank\">another link</A>. </P> </body> </HTML> " toke = HTMLTokenizer.new(page) assert("<h1>" == toke.getTag("h1", "h2", "h3").to_s.downcase) assert(HTMLTag.new("<a href=\"link.html\">") == toke.getTag("IMG", "A")) assert("links" == toke.getTrimmedText) assert(toke.getTag("IMG", "A").attr_hash['optional']) assert("_blank" == toke.getTag("IMG", "A").attr_hash['target']) end |
#test_namespace ⇒ Object
312 313 314 315 |
# File 'lib/html/htmltokenizer.rb', line 312 def test_namespace toke = HTMLTokenizer.new("<f:table xmlns:f=\"http://www.com/foo\">") assert("http://www.com/foo" == toke.getTag("f:table").attr_hash['xmlns:f']) end |