Ticket #65: hpricot_test.rb

File hpricot_test.rb, 1.2 kB (added by gonzoprosperity, 22 months ago)
Line 
1require File.dirname(__FILE__) + '/../test_helper'
2require 'hpricot'
3
4class HpricotTest < Test::Unit::TestCase
5
6  def test_parsing
7    str = <<-edoc
8    <html><body>
9    Lorem ipsum. Jolly roger, ding-dong sing-a-long
10    <object width="425" height="350">
11      <param name="movie" value="http://www.youtube.com/v/NbDQ4M_cuwA"></param>
12      <param name="wmode" value="transparent"></param>
13        <embed src="http://www.youtube.com/v/NbDQ4M_cuwA"
14          type="application/x-shockwave-flash" wmode="transparent" width="425" height="350">
15        </embed>
16    </object>
17    Check out my posting, I have bright mice in large clown cars.
18    <object width="425" height="350">
19      <param name="movie" value="http://www.youtube.com/v/foobar"></param>
20      <param name="wmode" value="transparent"></param>
21        <embed src="http://www.youtube.com/v/foobar"
22          type="application/x-shockwave-flash" wmode="transparent" width="425" height="350">
23        </embed>
24    </object>
25    </body></html?
26edoc
27    doc = Hpricot(str)
28    doc.search("//object/param[@value='http://www.youtube.com/v/NbDQ4M_cuwA']").each do |e|
29      puts '[' + e.to_s.strip() + ']' if !e.to_s.empty?
30    end
31   
32  end
33 
34end