fgraph 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +0 -1
- data/VERSION.yml +2 -2
- data/test/fgraph_test.rb +31 -31
- data/test/test_helper.rb +0 -1
- metadata +7 -23
data/Rakefile
CHANGED
@@ -14,7 +14,6 @@ begin
|
|
14
14
|
gem.add_dependency("httparty", ">= 0.5.0")
|
15
15
|
|
16
16
|
gem.add_development_dependency("shoulda", "~> 2.10.0")
|
17
|
-
gem.add_development_dependency("jnunemaker-matchy", "~> 0.4.0")
|
18
17
|
gem.add_development_dependency("mocha", "~> 0.9.0")
|
19
18
|
gem.add_development_dependency("fakeweb", "~> 1.2.0")
|
20
19
|
end
|
data/VERSION.yml
CHANGED
data/test/fgraph_test.rb
CHANGED
@@ -12,13 +12,13 @@ class FGraphTest < Test::Unit::TestCase
|
|
12
12
|
should "return 'id' if input 'id' is not a Hash" do
|
13
13
|
test_id = '123'
|
14
14
|
id = FGraph.get_id(test_id)
|
15
|
-
|
15
|
+
assert_equal test_id, id
|
16
16
|
end
|
17
17
|
|
18
18
|
should "return 'id' value from hash object if input 'id' is a Hash" do
|
19
19
|
test_id = { 'name' => 'Anthony', 'id' => '123' }
|
20
20
|
id = FGraph.get_id(test_id)
|
21
|
-
|
21
|
+
assert_equal test_id['id'], id
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
@@ -27,8 +27,8 @@ class FGraphTest < Test::Unit::TestCase
|
|
27
27
|
stub_get('/cocacola', 'object_cocacola.json')
|
28
28
|
object = FGraph.object('cocacola')
|
29
29
|
|
30
|
-
object.
|
31
|
-
object['name']
|
30
|
+
assert !object.nil?
|
31
|
+
assert_equal 'Coca-Cola', object['name']
|
32
32
|
end
|
33
33
|
|
34
34
|
should "call handle_response" do
|
@@ -117,8 +117,8 @@ class FGraphTest < Test::Unit::TestCase
|
|
117
117
|
:redirect_uri => FACEBOOK_OAUTH_REDIRECT_URI,
|
118
118
|
:code => FACEBOOK_OAUTH_CODE)
|
119
119
|
|
120
|
-
token['access_token']
|
121
|
-
token['expires']
|
120
|
+
assert_equal 'thisisanaccesstoken', token['access_token']
|
121
|
+
assert_equal '4000', token['expires']
|
122
122
|
end
|
123
123
|
end
|
124
124
|
|
@@ -203,33 +203,33 @@ class FGraphTest < Test::Unit::TestCase
|
|
203
203
|
end
|
204
204
|
|
205
205
|
should "raise no method error if missing method name does not start with object_ or me_" do
|
206
|
-
|
206
|
+
assert_raise NoMethodError do
|
207
207
|
FGraph.xyz_photos
|
208
|
-
end
|
208
|
+
end
|
209
209
|
end
|
210
210
|
end
|
211
211
|
|
212
212
|
context "FGraph.format_url" do
|
213
213
|
should "return URL without query string" do
|
214
214
|
formatted_url = FGraph.format_url('/test')
|
215
|
-
|
215
|
+
assert_equal "https://graph.facebook.com/test", formatted_url
|
216
216
|
end
|
217
217
|
|
218
218
|
should "return URL with query string with escaped value" do
|
219
219
|
formatted_url = FGraph.format_url('/test', {:username => 'john lim'})
|
220
|
-
|
220
|
+
assert_equal "https://graph.facebook.com/test?username=john+lim", formatted_url
|
221
221
|
end
|
222
222
|
|
223
223
|
should "return URL with multiple options" do
|
224
224
|
formatted_url = FGraph.format_url('/test', {:username => 'john', :age => 20})
|
225
|
-
formatted_url
|
226
|
-
formatted_url
|
227
|
-
formatted_url
|
225
|
+
assert formatted_url =~ /username=john/
|
226
|
+
assert formatted_url =~ /age=20/
|
227
|
+
assert formatted_url =~ /&/
|
228
228
|
end
|
229
229
|
|
230
230
|
should "return URL without empty options" do
|
231
231
|
formatted_url = FGraph.format_url('/test', {:username => 'john', :age => nil})
|
232
|
-
|
232
|
+
assert_equal "https://graph.facebook.com/test?username=john", formatted_url
|
233
233
|
end
|
234
234
|
end
|
235
235
|
|
@@ -237,7 +237,7 @@ class FGraphTest < Test::Unit::TestCase
|
|
237
237
|
should "return response object if there's no error" do
|
238
238
|
fb_response = {'name' => 'test'}
|
239
239
|
response = FGraph.handle_response(fb_response)
|
240
|
-
|
240
|
+
assert_equal fb_response, response
|
241
241
|
end
|
242
242
|
|
243
243
|
should "convert to FGraph::Collection object if response contain 'data' value" do
|
@@ -252,32 +252,32 @@ class FGraphTest < Test::Unit::TestCase
|
|
252
252
|
}
|
253
253
|
|
254
254
|
collection = FGraph.handle_response(fb_response)
|
255
|
-
|
256
|
-
|
255
|
+
assert_equal FGraph::Collection, collection.class
|
256
|
+
assert_equal fb_response['data'].length, collection.length
|
257
257
|
end
|
258
258
|
|
259
259
|
should "raise QueryParseError" do
|
260
|
-
|
260
|
+
assert_raise FGraph::QueryParseError do
|
261
261
|
object = FGraph.handle_response(response_error('QueryParseException'))
|
262
|
-
end
|
262
|
+
end
|
263
263
|
end
|
264
264
|
|
265
265
|
should "raise GraphMethodError" do
|
266
|
-
|
266
|
+
assert_raise FGraph::GraphMethodError do
|
267
267
|
object = FGraph.handle_response(response_error('GraphMethodException'))
|
268
|
-
end
|
268
|
+
end
|
269
269
|
end
|
270
270
|
|
271
271
|
should "raise OAuthError" do
|
272
|
-
|
272
|
+
assert_raise FGraph::OAuthError do
|
273
273
|
object = FGraph.handle_response(response_error('OAuthException'))
|
274
|
-
end
|
274
|
+
end
|
275
275
|
end
|
276
276
|
|
277
277
|
should "raise OAuthAccessTokenError" do
|
278
|
-
|
278
|
+
assert_raise FGraph::OAuthAccessTokenError do
|
279
279
|
object = FGraph.handle_response(response_error('OAuthAccessTokenException'))
|
280
|
-
end
|
280
|
+
end
|
281
281
|
end
|
282
282
|
end
|
283
283
|
|
@@ -295,12 +295,12 @@ class FGraphTest < Test::Unit::TestCase
|
|
295
295
|
}
|
296
296
|
|
297
297
|
collection = FGraph::Collection.new(response)
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
298
|
+
assert_equal response['data'].length, collection.length
|
299
|
+
assert_equal response['data'].first, collection.first
|
300
|
+
assert_equal response['paging']['next'], collection.next_url
|
301
|
+
assert_equal response['paging']['previous'], collection.previous_url
|
302
|
+
assert_equal({'offset' => '0', 'limit' => '2', 'access_token' => '101507589896698'}, collection.previous_options)
|
303
|
+
assert_equal({'offset' => '4', 'limit' => '2', 'access_token' => '101507589896698'}, collection.next_options)
|
304
304
|
end
|
305
305
|
end
|
306
306
|
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fgraph
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 9
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 5
|
9
|
-
-
|
10
|
-
version: 0.5.
|
9
|
+
- 1
|
10
|
+
version: 0.5.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Herryanto Siatono
|
@@ -50,26 +50,10 @@ dependencies:
|
|
50
50
|
version: 2.10.0
|
51
51
|
type: :development
|
52
52
|
version_requirements: *id002
|
53
|
-
- !ruby/object:Gem::Dependency
|
54
|
-
name: jnunemaker-matchy
|
55
|
-
prerelease: false
|
56
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
|
-
requirements:
|
59
|
-
- - ~>
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
hash: 15
|
62
|
-
segments:
|
63
|
-
- 0
|
64
|
-
- 4
|
65
|
-
- 0
|
66
|
-
version: 0.4.0
|
67
|
-
type: :development
|
68
|
-
version_requirements: *id003
|
69
53
|
- !ruby/object:Gem::Dependency
|
70
54
|
name: mocha
|
71
55
|
prerelease: false
|
72
|
-
requirement: &
|
56
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
73
57
|
none: false
|
74
58
|
requirements:
|
75
59
|
- - ~>
|
@@ -81,11 +65,11 @@ dependencies:
|
|
81
65
|
- 0
|
82
66
|
version: 0.9.0
|
83
67
|
type: :development
|
84
|
-
version_requirements: *
|
68
|
+
version_requirements: *id003
|
85
69
|
- !ruby/object:Gem::Dependency
|
86
70
|
name: fakeweb
|
87
71
|
prerelease: false
|
88
|
-
requirement: &
|
72
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
89
73
|
none: false
|
90
74
|
requirements:
|
91
75
|
- - ~>
|
@@ -97,7 +81,7 @@ dependencies:
|
|
97
81
|
- 0
|
98
82
|
version: 1.2.0
|
99
83
|
type: :development
|
100
|
-
version_requirements: *
|
84
|
+
version_requirements: *id004
|
101
85
|
description: Ruby Facebook Graph API
|
102
86
|
email: herryanto@gmail.com
|
103
87
|
executables: []
|