ud 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/ud.rb +2 -2
- data/tests/query_tests.rb +14 -33
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef94c79592b39fe5f56775e9d08eab3ea601db08
|
4
|
+
data.tar.gz: 3202e4b6ce4fe9bb52b2ef984c137f714d3091d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd4694a3b5970d1073129ffa8078c5727e4246161bcbd2bde9c4b02b4a4fe09248d5d9ae8a5cf6fe31bca65f3b8f82676076bbeaea1d604e928a0f8011be62b0
|
7
|
+
data.tar.gz: bbeede97c81c1496c534fbf8c48771f0e2145ef11506d4cb8b0ff7a0dc9c76ef2d1b6c05fa08de5846ebe435666d4edca59e02fa69cb7cd6412173c576e50938
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/ud.rb
CHANGED
@@ -13,7 +13,7 @@ module UD
|
|
13
13
|
|
14
14
|
# @return [String] the current gem's version
|
15
15
|
def version
|
16
|
-
'0.2.
|
16
|
+
'0.2.5'
|
17
17
|
end
|
18
18
|
|
19
19
|
# Get the search URL to query for a given term.
|
@@ -27,7 +27,7 @@ module UD
|
|
27
27
|
if api
|
28
28
|
"http://api.urbandictionary.com/v0/define?#{param}"
|
29
29
|
else
|
30
|
-
"http://www.urbandictionary.com/define.php
|
30
|
+
"http://www.urbandictionary.com/define.php?#{param}"
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
data/tests/query_tests.rb
CHANGED
@@ -5,7 +5,8 @@ require File.dirname(__FILE__) + '/fake_responses'
|
|
5
5
|
|
6
6
|
class UD_Query_test < Test::Unit::TestCase
|
7
7
|
|
8
|
-
|
8
|
+
API_URL = 'http://api.urbandictionary.com/v0/define'
|
9
|
+
ROOT_URL = 'http://www.urbandictionary.com/define.php'
|
9
10
|
|
10
11
|
def setup
|
11
12
|
@foo, @bar = [
|
@@ -36,30 +37,24 @@ class UD_Query_test < Test::Unit::TestCase
|
|
36
37
|
# == UD#search_url == #
|
37
38
|
|
38
39
|
def test_search_url_empty_term
|
39
|
-
assert_equal(
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
40
|
+
assert_equal("#{API_URL}?term=", UD.search_url())
|
41
|
+
assert_equal("#{API_URL}?term=", UD.search_url(''))
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_search_url_empty_term_nonapi
|
45
|
+
assert_equal("#{ROOT_URL}?term=", UD.search_url('', false))
|
45
46
|
end
|
46
47
|
|
47
48
|
def test_search_url_spaces_in_term
|
48
|
-
assert_equal(
|
49
|
-
"#{ROOT_URL}?term=a+b",
|
50
|
-
UD.search_url('a b'))
|
49
|
+
assert_equal("#{API_URL}?term=a+b", UD.search_url('a b'))
|
51
50
|
end
|
52
51
|
|
53
52
|
def test_search_url_encode_special_chars
|
54
|
-
assert_equal(
|
55
|
-
"#{ROOT_URL}?term=%3D",
|
56
|
-
UD.search_url('='))
|
53
|
+
assert_equal("#{API_URL}?term=%3D", UD.search_url('='))
|
57
54
|
end
|
58
55
|
|
59
56
|
def test_search_url
|
60
|
-
assert_equal(
|
61
|
-
"#{ROOT_URL}?term=foo",
|
62
|
-
UD.search_url('foo'))
|
57
|
+
assert_equal("#{API_URL}?term=foo", UD.search_url('foo'))
|
63
58
|
end
|
64
59
|
|
65
60
|
# == UD#query == #
|
@@ -69,29 +64,15 @@ class UD_Query_test < Test::Unit::TestCase
|
|
69
64
|
end
|
70
65
|
|
71
66
|
def test_query_two_results
|
72
|
-
|
73
|
-
expected = [
|
74
|
-
@foo, @bar
|
75
|
-
]
|
76
|
-
|
77
|
-
assert_equal(expected, UD.query('two_results', :count => 2))
|
67
|
+
assert_equal([@foo, @bar], UD.query('two_results', :count => 2))
|
78
68
|
end
|
79
69
|
|
80
70
|
def test_query_count
|
81
|
-
|
82
|
-
@foo
|
83
|
-
]
|
84
|
-
|
85
|
-
assert_equal(expected, UD.query('two_results', :count => 1))
|
71
|
+
assert_equal([@foo], UD.query('two_results', :count => 1))
|
86
72
|
end
|
87
73
|
|
88
74
|
def test_query_ratio
|
89
|
-
|
90
|
-
@foo
|
91
|
-
]
|
92
|
-
|
93
|
-
assert_equal(expected, UD.query('two_results', :count => 10, :ratio => 1.5))
|
75
|
+
assert_equal([@foo], UD.query('two_results', :count => 10, :ratio => 1.5))
|
94
76
|
end
|
95
|
-
|
96
77
|
end
|
97
78
|
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|