why-hpricot 0.6.204 → 0.6.207
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/hpricot/elements.rb +1 -1
- data/test/test_builder.rb +4 -4
- data/test/test_parser.rb +7 -7
- data/test/test_preserved.rb +4 -3
- metadata +1 -1
data/lib/hpricot/elements.rb
CHANGED
data/test/test_builder.rb
CHANGED
@@ -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 "
|
21
|
+
doc = Hpricot() { b "ۥ" }
|
21
22
|
assert_equal "<b>ۥ</b>", doc.to_html
|
22
|
-
assert_equal "
|
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
|
-
|
33
|
-
a = "\xed\x95\x9c\xea\xb8\x80"
|
33
|
+
a = '한글'
|
34
34
|
doc = Hpricot() { b a }
|
35
35
|
assert_equal "<b>한글</b>", doc.to_html
|
36
36
|
end
|
data/test/test_parser.rb
CHANGED
@@ -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
|
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
|
165
|
+
assert_equal 2, divs.length
|
166
166
|
imgs = @boingboing.search('//div/p/a/img')
|
167
|
-
assert_equal
|
168
|
-
assert_equal
|
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
|
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
|
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
|
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
|
data/test/test_preserved.rb
CHANGED
@@ -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
|
-
|
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
|
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
|
-
|
49
|
+
assert_roundtrip TestFiles::BOINGBOING
|
49
50
|
assert_roundtrip TestFiles::CY0
|
50
51
|
end
|
51
52
|
|