File: test_parse.rb

package info (click to toggle)
libyadis-ruby 0.3.4-2
  • links: PTS, VCS
  • area: main
  • in suites: lenny, squeeze
  • size: 440 kB
  • ctags: 372
  • sloc: ruby: 2,122; sh: 12; makefile: 2
file content (37 lines) | stat: -rw-r--r-- 1,426 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
require 'test/unit'
require 'yadis/parsehtml'

class YadisHTMLParseTestCase < Test::Unit::TestCase

  def check(x, html)
    result = html_yadis_location(html)
    assert_equal(x, result)
  end

  def test_valid
    check('foo', '<html><head><meta http-equiv="X-YADIS-LOCATION" content="foo"/></head></html>')
    
    check('foo', '<html><head><meta http-equiv="X-YADIS-LOCATION" content="foo"/></head></html>')
    check('foo', '<html><head><meta http-equiv="X-YADIS-LOCATION" content="foo"/></head></html>')
    check('foo', '<html><head><meta HTTP-EQUIV="X-YADIS-LOCATION" CONTENT="foo"/></head></html>')
    check('foo', '<html><head><meta HTTP-EQUIV="X-YADIS-Location" CONTENT="foo"/></head></html>')
    check('http://brian.myopenid.com/xrds', File.open('data/index.html').read)
    check('http://brian.myopenid.com/xrds', File.open('data/index_xrds.html').read)
    check('http://brian.myopenid.com/xrds', File.open('data/index_yadis.html').read)
  end

  def test_fail
    check(nil, '')
    check(nil, nil)
    check(nil, 5)
    check(nil, '<html></html>')

    # no content attr
    check(nil, '<html><head><meta http-equiv="x-yadis-location" /><meta http-equiv="X-YADIS-LOCATION" content="foo"/></head></html>')

    # not in head
    check(nil, '<html><meta http-equiv="X-YADIS-LOCATION" content="foo"/></html>')
    check(nil, '<html><body><meta http-equiv="X-YADIS-LOCATION" content="foo"/></html>')
  end

end