Class: TestHtmlFilter

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
lib/raw/util/html_filter.rb

Instance Method Summary collapse

Instance Method Details

#assert_filter(filtered, original) ⇒ Object



498
499
500
# File 'lib/raw/util/html_filter.rb', line 498

def assert_filter(filtered, original)
  assert_equal(filtered, original.html_filter)
end

#test_balancing_tagsObject



511
512
513
514
515
516
517
# File 'lib/raw/util/html_filter.rb', line 511

def test_balancing_tags
  assert_filter "<b>hello</b>", "<<b>hello</b>"
  assert_filter "<b>hello</b>", "<b>>hello</b>"
  assert_filter "<b>hello</b>", "<b>hello<</b>"
  assert_filter "<b>hello</b>", "<b>hello</b>>" 
  assert_filter "", "<>"
end

#test_basicsObject



506
507
508
509
# File 'lib/raw/util/html_filter.rb', line 506

def test_basics
  assert_filter '', ''
  assert_filter 'hello', 'hello'
end

#test_end_slashesObject



530
531
532
533
534
# File 'lib/raw/util/html_filter.rb', line 530

def test_end_slashes
  assert_filter '<img />', '<img>'
  assert_filter '<img />', '<img/>'
  assert_filter '', '<b/></b>'
end

#test_fix_quotesObject



502
503
504
# File 'lib/raw/util/html_filter.rb', line 502

def test_fix_quotes
  assert_filter '<img src="foo.jpg" />', "<img src=\"foo.jpg />"
end

#test_strip_singleObject



492
493
494
495
496
# File 'lib/raw/util/html_filter.rb', line 492

def test_strip_single
  hf = HtmlFilter.new
  assert_equal( '"', hf.send(:strip_single,'\"') )
  assert_equal( "\000", hf.send(:strip_single,'\0') )
end

#test_tag_completionObject



519
520
521
522
523
524
525
526
527
528
# File 'lib/raw/util/html_filter.rb', line 519

def test_tag_completion
  assert_filter "hello", "hello<b>"
  assert_filter "<b>hello</b>", "<b>hello"
  assert_filter "hello<b>world</b>", "hello<b>world"
  assert_filter "hello", "hello</b>"
  assert_filter "hello", "hello<b/>"
  assert_filter "hello<b>world</b>", "hello<b/>world"
  assert_filter "<b><b><b>hello</b></b></b>", "<b><b><b>hello"
  assert_filter "", "</b><b>"
end