Sha256: 9cdbf4d401f107ce0cedff20133c382a290c74bdc0192d7d97baa8bde4d4b1dc

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))

class TestStripTags < Test::Unit::TestCase

  def test_nil
    assert_nil Dryopteris.strip_tags(nil)
  end
  
  def test_empty_string
    assert_equal Dryopteris.strip_tags(""), ""
  end
  
  def test_return_empty_string_when_nothing_left
    assert_equal "", Dryopteris.strip_tags('<script>test</script>')
  end
  
  def test_removal_of_all_tags
    html = <<-HTML
      What's up <strong>doc</strong>?
    HTML
    stripped = Dryopteris.strip_tags(html)
    assert_equal "What's up doc?".strip, stripped.strip
  end
  
  def test_dont_remove_whitespace
    html = "Foo\nBar"
    assert_equal html, Dryopteris.strip_tags(html)
  end
  
  def test_dont_remove_whitespace_between_tags
    html = "<p>Foo</p>\n<p>Bar</p>"
    assert_equal "Foo\nBar", Dryopteris.strip_tags(html)
  end
  
  def test_removal_of_entities
    html = "<p>this is &lt; that &quot;&amp;&quot; the other &gt; boo&apos;ya</p>"
    assert_equal 'this is < that "&" the other > boo\'ya', Dryopteris.strip_tags(html)
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jmcnevin-dryopteris-0.1.2 test/test_strip_tags.rb