File: text_node_test.rb

package info (click to toggle)
ruby-rails-deprecated-sanitizer 1.0.3-3.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 244 kB
  • sloc: ruby: 1,737; makefile: 3
file content (51 lines) | stat: -rw-r--r-- 1,247 bytes parent folder | download | duplicates (3)
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
require 'test_helper'
require 'rails/deprecated_sanitizer/html-scanner/html/node'

class TextNodeTest < ActiveSupport::TestCase
  def setup
    @node = HTML::Text.new(nil, 0, 0, "hello, howdy, aloha, annyeong")
  end

  def test_to_s
    assert_equal "hello, howdy, aloha, annyeong", @node.to_s
  end

  def test_find_string
    assert_equal @node, @node.find("hello, howdy, aloha, annyeong")
    assert_equal false, @node.find("bogus")
  end

  def test_find_regexp
    assert_equal @node, @node.find(/an+y/)
    assert_nil @node.find(/b/)
  end

  def test_find_hash
    assert_equal @node, @node.find(:content => /howdy/)
    assert_nil @node.find(:content => /^howdy$/)
    assert_equal false, @node.find(:content => "howdy")
  end

  def test_find_other
    assert_nil @node.find(:hello)
  end

  def test_match_string
    assert @node.match("hello, howdy, aloha, annyeong")
    assert_equal false, @node.match("bogus")
  end

  def test_match_regexp
    assert_not_nil @node, @node.match(/an+y/)
    assert_nil @node.match(/b/)
  end

  def test_match_hash
    assert_not_nil @node, @node.match(:content => "howdy")
    assert_nil @node.match(:content => /^howdy$/)
  end

  def test_match_other
    assert_nil @node.match(:hello)
  end
end