hpricot 0.8.4-i386-mswin32 → 0.8.5-i386-mswin32

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,7 +9,7 @@ class TestAlter < Test::Unit::TestCase
9
9
  def setup
10
10
  @basic = Hpricot.parse(TestFiles::BASIC)
11
11
  end
12
-
12
+
13
13
  def test_before
14
14
  test0 = "<link rel='stylesheet' href='test0.css' />"
15
15
  @basic.at("link").before(test0)
@@ -27,14 +27,14 @@ class TestAlter < Test::Unit::TestCase
27
27
  assert_equal 'wrapper', ohmy[0].parent['id']
28
28
  assert_equal 'ohmy', Hpricot(@basic.to_html).at("#wrapper").children[0]['class']
29
29
  end
30
-
30
+
31
31
  def test_add_class
32
32
  first_p = (@basic/"p:first").add_class("testing123")
33
33
  assert first_p[0].get_attribute("class").split(" ").include?("testing123")
34
34
  assert (Hpricot(@basic.to_html)/"p:first")[0].attributes["class"].split(" ").include?("testing123")
35
35
  assert !(Hpricot(@basic.to_html)/"p:gt(0)")[0].attributes["class"].split(" ").include?("testing123")
36
36
  end
37
-
37
+
38
38
  def test_change_attributes
39
39
  all_ps = (@basic/"p").attr("title", "Some Title & Etc…")
40
40
  all_as = (@basic/"a").attr("href", "http://my_new_href.com")
@@ -43,7 +43,7 @@ class TestAlter < Test::Unit::TestCase
43
43
  assert_changed(@basic, "a", all_as) {|a| a.attributes["href"] == "http://my_new_href.com"}
44
44
  assert_changed(@basic, "link", all_lb) {|a| a.attributes["href"] == "link" }
45
45
  end
46
-
46
+
47
47
  def test_change_attributes2
48
48
  all_as = (@basic%"a").attributes["href"] = "http://my_new_href.com"
49
49
  all_ps = (@basic%"p").attributes["title"] = "Some Title & Etc…"
@@ -51,7 +51,7 @@ class TestAlter < Test::Unit::TestCase
51
51
  assert_equal (@basic%"p").raw_attributes["title"], "Some Title &amp; Etc&#8230;"
52
52
  assert_equal (@basic%"p").attributes["title"], "Some Title & Etc…"
53
53
  end
54
-
54
+
55
55
  def test_remove_attr
56
56
  all_rl = (@basic/"link").remove_attr("href")
57
57
  assert_changed(@basic, "link", all_rl) { |link| link['href'].nil? }
@@ -13,12 +13,12 @@ class TestParser < Test::Unit::TestCase
13
13
  assert_equal 4, @basic.search('//p').find_all { |x| x['class'] == 'para' }.length
14
14
  end
15
15
 
16
- # Test creating a new element
17
- def test_new_element
18
- elem = Hpricot::Elem.new('form')
19
- assert_not_nil(elem)
20
- assert_not_nil(elem.attributes)
21
- end
16
+ # Test creating a new element
17
+ def test_new_element
18
+ elem = Hpricot::Elem.new('form')
19
+ assert_not_nil(elem)
20
+ assert_not_nil(elem.attributes)
21
+ end
22
22
 
23
23
  def test_scan_text
24
24
  assert_equal 'FOO', Hpricot.make("FOO").children.first.content
@@ -31,7 +31,7 @@ class TestParser < Test::Unit::TestCase
31
31
  link = 'http://www.youtube.com/watch?v=TvSNXyNw26g&search=chris%20ware'
32
32
  assert_equal link, @boingboing.at("a[@href='#{link}']")['href']
33
33
  end
34
-
34
+
35
35
  def test_filter_contains
36
36
  @basic = Hpricot.parse(TestFiles::BASIC)
37
37
  assert_equal '<title>Sample XHTML</title>', @basic.search("title:contains('Sample')").to_s
@@ -48,7 +48,7 @@ class TestParser < Test::Unit::TestCase
48
48
  assert_equal 'link1', @basic.get_elements_by_tag_name('a')[0].get_attribute('id')
49
49
  assert_equal 'link1', @basic.get_elements_by_tag_name('body')[0].get_element_by_id('link1').get_attribute('id')
50
50
  end
51
-
51
+
52
52
  def test_get_elements_by_tag_name_star
53
53
  simple = Hpricot.parse("<div><p id='first'>First</p><p id='second'>Second</p></div>")
54
54
  assert_equal 3, simple.get_elements_by_tag_name("*").size
@@ -68,8 +68,8 @@ class TestParser < Test::Unit::TestCase
68
68
  end
69
69
 
70
70
  def scan_basic doc
71
- assert_kind_of Hpricot::XMLDecl, doc.children.first
72
- assert_not_equal doc.children.first.to_s, doc.children[1].to_s
71
+ assert_kind_of Hpricot::XMLDecl, doc.children.first
72
+ assert_not_equal doc.children.first.to_s, doc.children[1].to_s
73
73
  assert_equal 'link1', doc.at('#link1')['id']
74
74
  assert_equal 'link1', doc.at("p a")['id']
75
75
  assert_equal 'link1', (doc/:p/:a).first['id']
@@ -181,12 +181,12 @@ class TestParser < Test::Unit::TestCase
181
181
  assert_equal 1, @boingboing.search('//input[@checked]').length
182
182
  end
183
183
 
184
- def test_tag_case
185
- @tenderlove = Hpricot.parse(TestFiles::TENDERLOVE)
186
- assert_equal 2, @tenderlove.search('//a').length
187
- assert_equal 3, @tenderlove.search('//area').length
188
- assert_equal 2, @tenderlove.search('//meta').length
189
- end
184
+ def test_tag_case
185
+ @tenderlove = Hpricot.parse(TestFiles::TENDERLOVE)
186
+ assert_equal 2, @tenderlove.search('//a').length
187
+ assert_equal 3, @tenderlove.search('//area').length
188
+ assert_equal 2, @tenderlove.search('//meta').length
189
+ end
190
190
 
191
191
  def test_alt_predicates
192
192
  @boingboing = Hpricot.parse(TestFiles::BOINGBOING)
@@ -322,11 +322,11 @@ class TestParser < Test::Unit::TestCase
322
322
  def test_youtube_attr
323
323
  str = <<-edoc
324
324
  <html><body>
325
- Lorem ipsum. Jolly roger, ding-dong sing-a-long
325
+ Lorem ipsum. Jolly roger, ding-dong sing-a-long
326
326
  <object width="425" height="350">
327
327
  <param name="movie" value="http://www.youtube.com/v/NbDQ4M_cuwA"></param>
328
328
  <param name="wmode" value="transparent"></param>
329
- <embed src="http://www.youtube.com/v/NbDQ4M_cuwA"
329
+ <embed src="http://www.youtube.com/v/NbDQ4M_cuwA"
330
330
  type="application/x-shockwave-flash" wmode="transparent" width="425" height="350">
331
331
  </embed>
332
332
  </object>
@@ -334,7 +334,7 @@ class TestParser < Test::Unit::TestCase
334
334
  <object width="425" height="350">
335
335
  <param name="movie" value="http://www.youtube.com/v/foobar"></param>
336
336
  <param name="wmode" value="transparent"></param>
337
- <embed src="http://www.youtube.com/v/foobar"
337
+ <embed src="http://www.youtube.com/v/foobar"
338
338
  type="application/x-shockwave-flash" wmode="transparent" width="425" height="350">
339
339
  </embed>
340
340
  </object>
@@ -344,7 +344,7 @@ class TestParser < Test::Unit::TestCase
344
344
  assert_equal "http://www.youtube.com/v/NbDQ4M_cuwA",
345
345
  doc.at("//object/param[@value='http://www.youtube.com/v/NbDQ4M_cuwA']")['value']
346
346
  end
347
-
347
+
348
348
  # ticket #84 by jamezilla
349
349
  def test_screwed_xmlns
350
350
  doc = Hpricot(<<-edoc)
@@ -376,6 +376,14 @@ class TestParser < Test::Unit::TestCase
376
376
  assert_equal "button", doc.at("//form/input")['type']
377
377
  end
378
378
 
379
+ def test_escaped_quote
380
+ # Backslash '\' is not an escape character in HTML.
381
+ doc = Hpricot("<div><input type='text' value='C:\\dir\\' /><p id='test_id'>test</p></div>")
382
+ assert_equal "C:\\dir\\", doc.at("input")["value"]
383
+ doc = Hpricot('<div><input type="text" value="C:\\dir\\" /><p id="test_id">test</p></div>')
384
+ assert_equal "C:\\dir\\", doc.at("input")["value"]
385
+ end
386
+
379
387
  def test_filters
380
388
  @basic = Hpricot.parse(TestFiles::BASIC)
381
389
  assert_equal 0, (@basic/"title:parent").size
@@ -398,7 +406,7 @@ class TestParser < Test::Unit::TestCase
398
406
  END
399
407
  doc = Hpricot::XML(chunk)
400
408
  assert (doc/"//t:sam").size > 0 # at least this should probably work
401
- # assert (doc/"//sam").size > 0 # this would be nice
409
+ # assert (doc/"//sam").size > 0 # this would be nice
402
410
  end
403
411
 
404
412
  def test_uxs_ignores_non_entities
@@ -417,6 +425,14 @@ class TestParser < Test::Unit::TestCase
417
425
  end
418
426
  end
419
427
 
428
+ def test_uxs_handles_hexadecimal_values
429
+ if String.method_defined? :encoding
430
+ assert_equal "é", Hpricot.uxs('&#xe9;')
431
+ else
432
+ assert_equal "\303\251", Hpricot.uxs('&#xe9;')
433
+ end
434
+ end
435
+
420
436
  def test_uxs_handles_entities
421
437
  if String.method_defined? :encoding
422
438
  assert_equal "é", Hpricot.uxs('&eacute;')
@@ -453,5 +469,10 @@ class TestParser < Test::Unit::TestCase
453
469
  edoc
454
470
  assert_equal "7ff5e90iormq5niy6x98j75", doc.at("/html/head/meta[@name='verification']")['content']
455
471
  end
472
+
473
+ def test_nil_attr
474
+ # parsing this file was failing on JRuby
475
+ assert_nothing_raised {Hpricot.parse(TestFiles::BNQT)}
476
+ end
456
477
 
457
478
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hpricot
3
3
  version: !ruby/object:Gem::Version
4
- hash: 55
5
- prerelease: false
4
+ hash: 53
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 8
9
- - 4
10
- version: 0.8.4
9
+ - 5
10
+ version: 0.8.5
11
11
  platform: i386-mswin32
12
12
  authors:
13
13
  - why the lucky stiff
@@ -15,8 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-28 00:00:00 -06:00
19
- default_executable:
18
+ date: 2011-11-29 00:00:00 Z
20
19
  dependencies: []
21
20
 
22
21
  description: a swift, liberal HTML parser with a fantastic library
@@ -35,6 +34,7 @@ files:
35
34
  - README.md
36
35
  - Rakefile
37
36
  - test/files/basic.xhtml
37
+ - test/files/bnqt.html
38
38
  - test/files/boingboing.html
39
39
  - test/files/cy0.html
40
40
  - test/files/immob.html
@@ -85,7 +85,6 @@ files:
85
85
  - lib/fast_xs.rb
86
86
  - lib/fast_xs/1.8/fast_xs.so
87
87
  - lib/fast_xs/1.9/fast_xs.so
88
- has_rdoc: true
89
88
  homepage: http://code.whytheluckystiff.net/hpricot/
90
89
  licenses: []
91
90
 
@@ -120,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
119
  requirements: []
121
120
 
122
121
  rubyforge_project: hobix
123
- rubygems_version: 1.3.7
122
+ rubygems_version: 1.8.6
124
123
  signing_key:
125
124
  specification_version: 3
126
125
  summary: a swift, liberal HTML parser with a fantastic library