murlsh 0.4.0 → 0.5.0

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.
@@ -1,43 +0,0 @@
1
- $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
-
3
- require 'murlsh'
4
-
5
- require 'test/unit'
6
-
7
- class GetTitleTest < Test::Unit::TestCase
8
-
9
- def noop(url)
10
- assert_equal(url, Murlsh.get_title(url))
11
- end
12
-
13
- def test_nil
14
- noop(nil)
15
- end
16
-
17
- def test_empty
18
- noop('')
19
- end
20
-
21
- def test_invalid_url
22
- noop('foo')
23
- end
24
-
25
- def test_invalid_host
26
- noop('http://28fac7a1ac51976c90016509d97c89ba.edu/')
27
- end
28
-
29
- def test_good
30
- assert_equal('Google', Murlsh.get_title('http://www.google.com/'))
31
- end
32
-
33
- def test_failproof_true
34
- noop(Murlsh.get_title('http://x.boedicker.org/', :failproof => true))
35
- end
36
-
37
- def test_failproof_false
38
- assert_raise SocketError do
39
- Murlsh.get_title('http://x.boedicker.org/', :failproof => false)
40
- end
41
- end
42
-
43
- end
@@ -1,71 +0,0 @@
1
- $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
-
3
- require 'murlsh'
4
-
5
- require 'test/unit'
6
-
7
- class ReferrerTest < Test::Unit::TestCase
8
-
9
- def setup
10
- @qmap = {
11
- /www\.foo\.com\/search/ => 'q',
12
- }
13
- end
14
-
15
- def instantiate(url)
16
- Murlsh::Referrer.new(url)
17
- end
18
-
19
- def test_url_nil
20
- r = instantiate(nil)
21
- assert_equal('', r.hostpath)
22
- assert_equal({}, r.query_string)
23
- end
24
-
25
- def test_url_nil_block
26
- r = instantiate(nil)
27
- r.search_query(@qmap) { |x| flunk }
28
- end
29
-
30
- def test_url_empty
31
- r = instantiate('')
32
- assert_equal('', r.hostpath)
33
- assert_equal({}, r.query_string)
34
- end
35
-
36
- def test_url_empty_block
37
- r = instantiate('')
38
- r.search_query(@qmap) { |x| flunk }
39
- end
40
-
41
- def test_hostpath_not_found
42
- r = instantiate('http://www.bar.com/search?q=test&a=1&b=2&c=3')
43
- assert_equal(nil, r.search_query(@qmap))
44
- end
45
-
46
- def test_hostpath_not_found_block
47
- r = instantiate('http://www.bar.com/search?q=test&a=1&b=2&c=3')
48
- r.search_query(@qmap) { |x| flunk }
49
- end
50
-
51
- def test_query_not_found
52
- r = instantiate('http://www.foo.com/search?a=1&b=2&c=3')
53
- assert_equal(nil, r.search_query(@qmap))
54
- end
55
-
56
- def test_query_not_found_block
57
- r = instantiate('http://www.foo.com/search?a=1&b=2&c=3')
58
- r.search_query(@qmap) { |x| flunk }
59
- end
60
-
61
- def test_good
62
- r = instantiate('http://www.foo.com/search?q=test&a=1&b=2&c=3')
63
- assert_equal('test', r.search_query(@qmap))
64
- end
65
-
66
- def test_good_block
67
- r = instantiate('http://www.foo.com/search?q=test&a=1&b=2&c=3')
68
- r.search_query(@qmap) { |x| assert_equal('test', x) }
69
- end
70
-
71
- end