why-hpricot 0.6.204 → 0.6.207

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -495,7 +495,7 @@ module Hpricot
495
495
  end
496
496
 
497
497
  filter 'text()' do |val,i|
498
- !self.inner_text.strip.empty?
498
+ self.children.grep(Hpricot::Text).detect { |x| x.content =~ /\S/ } if self.children
499
499
  end
500
500
 
501
501
  filter '@' do |attr,val,i|
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  #!/usr/bin/env ruby
2
3
 
3
4
  require 'test/unit'
@@ -17,9 +18,9 @@ class TestBuilder < Test::Unit::TestCase
17
18
  end
18
19
 
19
20
  def test_latin1_entities
20
- doc = Hpricot() { b "\200\225" }
21
+ doc = Hpricot() { b "ۥ" }
21
22
  assert_equal "<b>&#8364;&#8226;</b>", doc.to_html
22
- assert_equal "\342\202\254\342\200\242", doc.at("text()").to_s
23
+ assert_equal "ۥ", doc.at("text()").to_s
23
24
  end
24
25
 
25
26
  def test_escaping_attrs
@@ -29,8 +30,7 @@ class TestBuilder < Test::Unit::TestCase
29
30
  end
30
31
 
31
32
  def test_korean_utf8_entities
32
- # a = '한글'
33
- a = "\xed\x95\x9c\xea\xb8\x80"
33
+ a = '한글'
34
34
  doc = Hpricot() { b a }
35
35
  assert_equal "<b>&#54620;&#44544;</b>", doc.to_html
36
36
  end
@@ -122,7 +122,7 @@ class TestParser < Test::Unit::TestCase
122
122
  assert_equal 60, @boingboing.search("h3").length
123
123
  assert_equal 59, @boingboing.search("h3[text()!='College kids reportedly taking more smart drugs']").length
124
124
  assert_equal 17, @boingboing.search("h3[text()$='s']").length
125
- assert_equal 129, @boingboing.search("p[text()]").length
125
+ assert_equal 116, @boingboing.search("p[text()]").length
126
126
  assert_equal 211, @boingboing.search("p").length
127
127
  end
128
128
 
@@ -162,10 +162,10 @@ class TestParser < Test::Unit::TestCase
162
162
  assert_equal 60, @boingboing.search("/*/body//p[@class='posted']").length
163
163
  assert_equal 18, @boingboing.search("//script").length
164
164
  divs = @boingboing.search("//script/../div")
165
- assert_equal 1, divs.length
165
+ assert_equal 2, divs.length
166
166
  imgs = @boingboing.search('//div/p/a/img')
167
- assert_equal 15, imgs.length
168
- assert_equal 17, @boingboing.search('//div').search('p/a/img').length
167
+ assert_equal 16, imgs.length
168
+ assert_equal 16, @boingboing.search('//div').search('p/a/img').length
169
169
  assert imgs.all? { |x| x.name == 'img' }
170
170
  end
171
171
 
@@ -173,10 +173,10 @@ class TestParser < Test::Unit::TestCase
173
173
  @boingboing = Hpricot.parse(TestFiles::BOINGBOING)
174
174
  assert_equal 2, @boingboing.search('//link[@rel="alternate"]').length
175
175
  p_imgs = @boingboing.search('//div/p[/a/img]')
176
- assert_equal 15, p_imgs.length
176
+ assert_equal 16, p_imgs.length
177
177
  assert p_imgs.all? { |x| x.name == 'p' }
178
178
  p_imgs = @boingboing.search('//div/p[a/img]')
179
- assert_equal 18, p_imgs.length
179
+ assert_equal 16, p_imgs.length
180
180
  assert p_imgs.all? { |x| x.name == 'p' }
181
181
  assert_equal 1, @boingboing.search('//input[@checked]').length
182
182
  end
@@ -219,7 +219,7 @@ class TestParser < Test::Unit::TestCase
219
219
  def test_many_paths
220
220
  @boingboing = Hpricot.parse(TestFiles::BOINGBOING)
221
221
  assert_equal 62, @boingboing.search('p.posted, link[@rel="alternate"]').length
222
- assert_equal 20, @boingboing.search('//div/p[a/img]|//link[@rel="alternate"]').length
222
+ assert_equal 18, @boingboing.search('//div/p[a/img]|//link[@rel="alternate"]').length
223
223
  end
224
224
 
225
225
  def test_stacked_search
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  #!/usr/bin/env ruby
2
3
 
3
4
  require 'test/unit'
@@ -9,7 +10,7 @@ class TestPreserved < Test::Unit::TestCase
9
10
  doc = Hpricot(str)
10
11
  yield doc if block_given?
11
12
  str2 = doc.to_original_html
12
- [*str].zip([*str2]).each do |s1, s2|
13
+ str.lines.zip(str2.lines).each do |s1, s2|
13
14
  assert_equal s1, s2
14
15
  end
15
16
  end
@@ -40,12 +41,12 @@ class TestPreserved < Test::Unit::TestCase
40
41
 
41
42
  def test_escaping_of_contents
42
43
  doc = Hpricot(TestFiles::BOINGBOING)
43
- assert_equal "Fukuda\342\200\231s Automatic Door opens around your body as you pass through it. The idea is to save energy and keep the room clean.", doc.at("img[@alt='200606131240']").next.to_s.strip
44
+ assert_equal "Fukuda’s Automatic Door opens around your body as you pass through it. The idea is to save energy and keep the room clean.", doc.at("img[@alt='200606131240']").next.to_s.strip
44
45
  end
45
46
 
46
47
  def test_files
47
48
  assert_roundtrip TestFiles::BASIC
48
- # assert_roundtrip TestFiles::BOINGBOING
49
+ assert_roundtrip TestFiles::BOINGBOING
49
50
  assert_roundtrip TestFiles::CY0
50
51
  end
51
52
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: why-hpricot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.204
4
+ version: 0.6.207
5
5
  platform: ruby
6
6
  authors:
7
7
  - why the lucky stiff