Sha256: 041594e9e36c44b64014563f7d35d93202374a3d00aebadf09ed4c6034b6a4e6

Contents?: true

Size: 1.22 KB

Versions: 15

Compression:

Stored size: 1.22 KB

Contents

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

Version data entries

15 entries across 15 versions & 7 rubygems

Version Path
rails-deprecated_sanitizer-1.0.4 test/text_node_test.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/rails-deprecated_sanitizer-1.0.3/test/text_node_test.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/rails-deprecated_sanitizer-1.0.3/test/text_node_test.rb
angular-rails4-templates-0.4.1 vendor/ruby/2.1.0/gems/rails-deprecated_sanitizer-1.0.3/test/text_node_test.rb
angular-rails4-templates-0.4.0 vendor/ruby/2.1.0/gems/rails-deprecated_sanitizer-1.0.3/test/text_node_test.rb
angular-rails4-templates-0.3.0 vendor/ruby/2.1.0/gems/rails-deprecated_sanitizer-1.0.3/test/text_node_test.rb
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/rails-deprecated_sanitizer-1.0.3/test/text_node_test.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/rails-deprecated_sanitizer-1.0.3/test/text_node_test.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/rails-deprecated_sanitizer-1.0.3/test/text_node_test.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/rails-deprecated_sanitizer-1.0.3/test/text_node_test.rb
shoppe-paypal-1.1.0 vendor/bundle/ruby/2.1.0/gems/rails-deprecated_sanitizer-1.0.3/test/text_node_test.rb
rails-deprecated_sanitizer-1.0.3 test/text_node_test.rb
rails-deprecated_sanitizer-1.0.2 test/text_node_test.rb
rails-deprecated_sanitizer-1.0.1 test/text_node_test.rb
rails-deprecated_sanitizer-1.0.0 test/text_node_test.rb