Sha256: 62a9f7a13fa8daeababfbd30346024a19602567e02d351cbc19e4df8a681c98e

Contents?: true

Size: 803 Bytes

Versions: 65

Compression:

Stored size: 803 Bytes

Contents

#!/usr/bin/env ruby

require 'test/unit'
require 'hpricot'
require 'load_files'

class TestParser < Test::Unit::TestCase
  def test_roundtrip
    @basic = Hpricot.parse(TestFiles::BASIC)
    %w[link link[2] body #link1 a p.ohmy].each do |css_sel|
      ele = @basic.at(css_sel)
      assert_equal ele, @basic.at(ele.css_path)
      assert_equal ele, @basic.at(ele.xpath)
    end
  end
  def test_attr_brackets
    doc = Hpricot('<input name="vendor[porkpies]"/>')
    assert_equal 1, (doc/'input[@name^="vendor[porkpies]"]').length
    assert_equal 1, (doc/'input[@name="vendor[porkpies]"]').length
    assert_equal 0, (doc/'input[@name$="]]]]]"]').length

    doc = Hpricot('<input name="vendor[porkpies][meaty]"/>')
    assert_equal 1, (doc/'input[@name^="vendor[porkpies][meaty]"]').length
  end
end

Version data entries

65 entries across 65 versions & 15 rubygems

Version Path
webtranslateit-hpricot-0.9.0 test/test_paths.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/hpricot-0.8.6/test/test_paths.rb
adamh-hpricot-0.6.168 test/test_paths.rb
adamh-hpricot-0.6.169 test/test_paths.rb
adamh-hpricot-0.6.170 test/test_paths.rb
adamh-hpricot-0.6.171 test/test_paths.rb
adamh-hpricot-0.6.210 test/test_paths.rb
adamh-hpricot-0.6.211 test/test_paths.rb
adamh-hpricot-0.7.229 test/test_paths.rb
hpricot-hpricot-0.7.229 test/test_paths.rb
jerryvos-hpricot-0.8.1 test/test_paths.rb
jerryvos-jerryvos-hpricot-0.7.230 test/test_paths.rb
jordan-brough-hpricot-0.7.229 test/test_paths.rb
martiantim-hpricot-0.8.236 test/test_paths.rb
mperham-hpricot-0.8.1.1 test/test_paths.rb
stepheneb-hpricot-0.8.265 test/test_paths.rb
stepheneb-hpricot-0.8.268 test/test_paths.rb
why-hpricot-0.6.201 test/test_paths.rb
why-hpricot-0.6.204 test/test_paths.rb
why-hpricot-0.6.207 test/test_paths.rb