koala 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  shared_examples_for "Koala RestAPI" do
2
2
  # REST_CALL
3
3
  describe "when making a rest request" do
4
- it "should use the proper path" do
4
+ it "uses the proper path" do
5
5
  method = stub('methodName')
6
6
  @api.should_receive(:api).with(
7
7
  "method/#{method}",
@@ -13,7 +13,7 @@ shared_examples_for "Koala RestAPI" do
13
13
  @api.rest_call(method)
14
14
  end
15
15
 
16
- it "should always use the rest api" do
16
+ it "always uses the rest api" do
17
17
  @api.should_receive(:api).with(
18
18
  anything,
19
19
  anything,
@@ -24,7 +24,7 @@ shared_examples_for "Koala RestAPI" do
24
24
  @api.rest_call('anything')
25
25
  end
26
26
 
27
- it "should set the read_only option to true if the method is listed in the read-only list" do
27
+ it "sets the read_only option to true if the method is listed in the read-only list" do
28
28
  method = Koala::Facebook::RestAPI::READ_ONLY_METHODS.first
29
29
 
30
30
  @api.should_receive(:api).with(
@@ -37,7 +37,7 @@ shared_examples_for "Koala RestAPI" do
37
37
  @api.rest_call(method)
38
38
  end
39
39
 
40
- it "should set the read_only option to false if the method is not inthe read-only list" do
40
+ it "sets the read_only option to false if the method is not inthe read-only list" do
41
41
  method = "I'm not a read-only method"
42
42
 
43
43
  @api.should_receive(:api).with(
@@ -51,7 +51,7 @@ shared_examples_for "Koala RestAPI" do
51
51
  end
52
52
 
53
53
 
54
- it "should take an optional hash of arguments" do
54
+ it "takes an optional hash of arguments" do
55
55
  args = {:arg1 => 'arg1'}
56
56
 
57
57
  @api.should_receive(:api).with(
@@ -64,7 +64,7 @@ shared_examples_for "Koala RestAPI" do
64
64
  @api.rest_call('anything', args)
65
65
  end
66
66
 
67
- it "should always ask for JSON" do
67
+ it "always asks for JSON" do
68
68
  @api.should_receive(:api).with(
69
69
  anything,
70
70
  hash_including('format' => 'json'),
@@ -75,7 +75,7 @@ shared_examples_for "Koala RestAPI" do
75
75
  @api.rest_call('anything')
76
76
  end
77
77
 
78
- it "should pass any options provided to the API" do
78
+ it "passes any options provided to the API" do
79
79
  options = {:a => 2}
80
80
 
81
81
  @api.should_receive(:api).with(
@@ -111,13 +111,13 @@ shared_examples_for "Koala RestAPI" do
111
111
  @api.rest_call('anything', {}, {}, method)
112
112
  end
113
113
 
114
- it "should throw an APIError if the result hash has an error key" do
114
+ it "throws an APIError if the result hash has an error key" do
115
115
  Koala.stub(:make_request).and_return(Koala::Response.new(500, {"error_code" => "An error occurred!"}, {}))
116
116
  lambda { @api.rest_call("koppel", {}) }.should raise_exception(Koala::Facebook::APIError)
117
117
  end
118
118
 
119
119
  describe "when making a FQL request" do
120
- it "should call fql.query method" do
120
+ it "calls fql.query method" do
121
121
  @api.should_receive(:rest_call).with(
122
122
  "fql.query", anything, anything
123
123
  ).and_return(Koala::Response.new(200, "2", {}))
@@ -125,7 +125,7 @@ shared_examples_for "Koala RestAPI" do
125
125
  @api.fql_query stub('query string')
126
126
  end
127
127
 
128
- it "should pass a query argument" do
128
+ it "passes a query argument" do
129
129
  query = stub('query string')
130
130
 
131
131
  @api.should_receive(:rest_call).with(
@@ -135,13 +135,13 @@ shared_examples_for "Koala RestAPI" do
135
135
  @api.fql_query(query)
136
136
  end
137
137
 
138
- it "should pass on any other arguments provided" do
138
+ it "passes on any other arguments provided" do
139
139
  args = {:a => 2}
140
140
  @api.should_receive(:rest_call).with(anything, hash_including(args), anything)
141
141
  @api.fql_query("a query", args)
142
142
  end
143
143
 
144
- it "should pass on any http options provided" do
144
+ it "passes on any http options provided" do
145
145
  opts = {:a => 2}
146
146
  @api.should_receive(:rest_call).with(anything, anything, hash_including(opts))
147
147
  @api.fql_query("a query", {}, opts)
@@ -149,7 +149,7 @@ shared_examples_for "Koala RestAPI" do
149
149
  end
150
150
 
151
151
  describe "when making a FQL-multiquery request" do
152
- it "should call fql.multiquery method" do
152
+ it "calls fql.multiquery method" do
153
153
  @api.should_receive(:rest_call).with(
154
154
  "fql.multiquery", anything, anything
155
155
  ).and_return({})
@@ -157,7 +157,7 @@ shared_examples_for "Koala RestAPI" do
157
157
  @api.fql_multiquery 'query string'
158
158
  end
159
159
 
160
- it "should pass a queries argument" do
160
+ it "passes a queries argument" do
161
161
  queries = stub('query string')
162
162
  queries_json = "some JSON"
163
163
  MultiJson.stub(:encode).with(queries).and_return(queries_json)
@@ -186,30 +186,34 @@ shared_examples_for "Koala RestAPI" do
186
186
  results.should == expected_results
187
187
  end
188
188
 
189
- it "should pass on any other arguments provided" do
189
+ it "passes on any other arguments provided" do
190
190
  args = {:a => 2}
191
191
  @api.should_receive(:rest_call).with(anything, hash_including(args), anything)
192
192
  @api.fql_multiquery("a query", args)
193
193
  end
194
194
 
195
- it "should pass on any http options provided" do
195
+ it "passes on any http options provided" do
196
196
  opts = {:a => 2}
197
197
  @api.should_receive(:rest_call).with(anything, anything, hash_including(opts))
198
198
  @api.fql_multiquery("a query", {}, opts)
199
199
  end
200
200
  end
201
201
  end
202
+
203
+ it "can use the beta tier" do
204
+ @api.fql_query("select first_name from user where uid = #{KoalaTest.user2_id}", {}, :beta => true)
205
+ end
202
206
  end
203
207
 
204
208
  shared_examples_for "Koala RestAPI with an access token" do
205
209
  # FQL
206
- it "should be able to access public information via FQL" do
210
+ it "can access public information via FQL" do
207
211
  result = @api.fql_query("select first_name from user where uid = #{KoalaTest.user2_id}")
208
212
  result.size.should == 1
209
213
  result.first['first_name'].should == KoalaTest.user2_name
210
214
  end
211
215
 
212
- it "should be able to access public information via FQL.multiquery" do
216
+ it "can access public information via FQL.multiquery" do
213
217
  result = @api.fql_multiquery(
214
218
  :query1 => "select first_name from user where uid = #{KoalaTest.user2_id}",
215
219
  :query2 => "select first_name from user where uid = #{KoalaTest.user1_id}"
@@ -219,7 +223,7 @@ shared_examples_for "Koala RestAPI with an access token" do
219
223
  result["query2"].first['first_name'].should == KoalaTest.user1_name
220
224
  end
221
225
 
222
- it "should be able to access protected information via FQL" do
226
+ it "can access protected information via FQL" do
223
227
  # Tests agains the permissions fql table
224
228
 
225
229
  # get the current user's ID
@@ -235,8 +239,7 @@ shared_examples_for "Koala RestAPI with an access token" do
235
239
  result.first["read_stream"].should == 1
236
240
  end
237
241
 
238
-
239
- it "should be able to access protected information via FQL.multiquery" do
242
+ it "can access protected information via FQL.multiquery" do
240
243
  result = @api.fql_multiquery(
241
244
  :query1 => "select post_id from stream where source_id = me()",
242
245
  :query2 => "select fromid from comment where post_id in (select post_id from #query1)",
@@ -245,20 +248,57 @@ shared_examples_for "Koala RestAPI with an access token" do
245
248
  result.size.should == 3
246
249
  result.keys.should include("query1", "query2", "query3")
247
250
  end
251
+
252
+
253
+ describe ".set_app_properties" do
254
+ it "sends Facebook the properties JSON-encoded as :properties" do
255
+ props = {:a => 2, :c => [1, 2, "d"]}
256
+ @api.should_receive(:rest_call).with(anything, hash_including(:properties => MultiJson.encode(props)), anything, anything)
257
+ @api.set_app_properties(props)
258
+ end
259
+
260
+ it "calls the admin.setAppProperties method" do
261
+ @api.should_receive(:rest_call).with("admin.setAppProperties", anything, anything, anything)
262
+ @api.set_app_properties({})
263
+ end
264
+
265
+ it "includes any other provided arguments" do
266
+ args = {:c => 3, :d => "a"}
267
+ @api.should_receive(:rest_call).with(anything, hash_including(args), anything, anything)
268
+ @api.set_app_properties({:a => 2}, args)
269
+ end
270
+
271
+ it "includes any http_options provided" do
272
+ opts = {:c => 3, :d => "a"}
273
+ @api.should_receive(:rest_call).with(anything, anything, opts, anything)
274
+ @api.set_app_properties({}, {}, opts)
275
+ end
276
+
277
+ it "makes a POST" do
278
+ @api.should_receive(:rest_call).with(anything, anything, anything, "post")
279
+ @api.set_app_properties({})
280
+ end
248
281
 
282
+ it "can set app properties using the app's access token" do
283
+ oauth = Koala::Facebook::OAuth.new(KoalaTest.app_id, KoalaTest.secret)
284
+ app_token = oauth.get_app_access_token
285
+ @app_api = Koala::Facebook::API.new(app_token)
286
+ @app_api.set_app_properties(:desktop => 0).should be_true
287
+ end
288
+ end
249
289
  end
250
290
 
251
291
 
252
292
  shared_examples_for "Koala RestAPI without an access token" do
253
293
  # FQL_QUERY
254
294
  describe "when making a FQL request" do
255
- it "should be able to access public information via FQL" do
295
+ it "can access public information via FQL" do
256
296
  result = @api.fql_query("select first_name from user where uid = #{KoalaTest.user2_id}")
257
297
  result.size.should == 1
258
298
  result.first['first_name'].should == KoalaTest.user2_name
259
299
  end
260
300
 
261
- it "should be able to access public information via FQL.multiquery" do
301
+ it "can access public information via FQL.multiquery" do
262
302
  result = @api.fql_multiquery(
263
303
  :query1 => "select first_name from user where uid = #{KoalaTest.user2_id}",
264
304
  :query2 => "select first_name from user where uid = #{KoalaTest.user1_id}"
@@ -268,11 +308,11 @@ shared_examples_for "Koala RestAPI without an access token" do
268
308
  result["query2"].first['first_name'].should == KoalaTest.user1_name
269
309
  end
270
310
 
271
- it "should not be able to access protected information via FQL" do
311
+ it "can't access protected information via FQL" do
272
312
  lambda { @api.fql_query("select read_stream from permissions where uid = #{KoalaTest.user2_id}") }.should raise_error(Koala::Facebook::APIError)
273
313
  end
274
314
 
275
- it "should not be able to access protected information via FQL.multiquery" do
315
+ it "can't access protected information via FQL.multiquery" do
276
316
  lambda {
277
317
  @api.fql_multiquery(
278
318
  :query1 => "select post_id from stream where source_id = me()",
@@ -282,4 +322,8 @@ shared_examples_for "Koala RestAPI without an access token" do
282
322
  }.should raise_error(Koala::Facebook::APIError)
283
323
  end
284
324
  end
325
+
326
+ it "can't use set_app_properties" do
327
+ lambda { @api.set_app_properties(:desktop => 0) }.should raise_error(Koala::Facebook::APIError)
328
+ end
285
329
  end
metadata CHANGED
@@ -1,72 +1,95 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: koala
3
- version: !ruby/object:Gem::Version
4
- version: 1.2.0
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
5
  prerelease:
6
+ segments:
7
+ - 1
8
+ - 2
9
+ - 1
10
+ version: 1.2.1
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Alex Koppel, Chris Baclig, Rafi Jacoby, Context Optional
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2011-09-27 00:00:00.000000000Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
17
+
18
+ date: 2011-10-04 00:00:00 +02:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ type: :runtime
15
23
  name: multi_json
16
- requirement: &70248641333480 !ruby/object:Gem::Requirement
24
+ version_requirements: &id001 !ruby/object:Gem::Requirement
17
25
  none: false
18
- requirements:
26
+ requirements:
19
27
  - - ~>
20
- - !ruby/object:Gem::Version
21
- version: '1.0'
22
- type: :runtime
28
+ - !ruby/object:Gem::Version
29
+ hash: 15
30
+ segments:
31
+ - 1
32
+ - 0
33
+ version: "1.0"
34
+ requirement: *id001
23
35
  prerelease: false
24
- version_requirements: *70248641333480
25
- - !ruby/object:Gem::Dependency
36
+ - !ruby/object:Gem::Dependency
37
+ type: :runtime
26
38
  name: faraday
27
- requirement: &70248641333000 !ruby/object:Gem::Requirement
39
+ version_requirements: &id002 !ruby/object:Gem::Requirement
28
40
  none: false
29
- requirements:
41
+ requirements:
30
42
  - - ~>
31
- - !ruby/object:Gem::Version
43
+ - !ruby/object:Gem::Version
44
+ hash: 3
45
+ segments:
46
+ - 0
47
+ - 7
48
+ - 0
32
49
  version: 0.7.0
33
- type: :runtime
50
+ requirement: *id002
34
51
  prerelease: false
35
- version_requirements: *70248641333000
36
- - !ruby/object:Gem::Dependency
52
+ - !ruby/object:Gem::Dependency
53
+ type: :development
37
54
  name: rspec
38
- requirement: &70248641332520 !ruby/object:Gem::Requirement
55
+ version_requirements: &id003 !ruby/object:Gem::Requirement
39
56
  none: false
40
- requirements:
57
+ requirements:
41
58
  - - ~>
42
- - !ruby/object:Gem::Version
43
- version: '2.5'
44
- type: :development
59
+ - !ruby/object:Gem::Version
60
+ hash: 9
61
+ segments:
62
+ - 2
63
+ - 5
64
+ version: "2.5"
65
+ requirement: *id003
45
66
  prerelease: false
46
- version_requirements: *70248641332520
47
- - !ruby/object:Gem::Dependency
67
+ - !ruby/object:Gem::Dependency
68
+ type: :development
48
69
  name: rake
49
- requirement: &70248641332040 !ruby/object:Gem::Requirement
70
+ version_requirements: &id004 !ruby/object:Gem::Requirement
50
71
  none: false
51
- requirements:
72
+ requirements:
52
73
  - - ~>
53
- - !ruby/object:Gem::Version
74
+ - !ruby/object:Gem::Version
75
+ hash: 49
76
+ segments:
77
+ - 0
78
+ - 8
79
+ - 7
54
80
  version: 0.8.7
55
- type: :development
81
+ requirement: *id004
56
82
  prerelease: false
57
- version_requirements: *70248641332040
58
- description: Koala is a lightweight, flexible Ruby SDK for Facebook. It allows read/write
59
- access to the social graph via the Graph and REST APIs, as well as support for realtime
60
- updates and OAuth and Facebook Connect authentication. Koala is fully tested and
61
- supports Net::HTTP and Typhoeus connections out of the box and can accept custom
62
- modules for other services.
83
+ description: Koala is a lightweight, flexible Ruby SDK for Facebook. It allows read/write access to the social graph via the Graph and REST APIs, as well as support for realtime updates and OAuth and Facebook Connect authentication. Koala is fully tested and supports Net::HTTP and Typhoeus connections out of the box and can accept custom modules for other services.
63
84
  email: alex@alexkoppel.com
64
85
  executables: []
86
+
65
87
  extensions: []
66
- extra_rdoc_files:
88
+
89
+ extra_rdoc_files:
67
90
  - readme.md
68
91
  - CHANGELOG
69
- files:
92
+ files:
70
93
  - .autotest
71
94
  - .gitignore
72
95
  - .travis.yml
@@ -83,6 +106,7 @@ files:
83
106
  - lib/koala/graph_batch_api.rb
84
107
  - lib/koala/graph_collection.rb
85
108
  - lib/koala/http_service.rb
109
+ - lib/koala/multipart_request.rb
86
110
  - lib/koala/oauth.rb
87
111
  - lib/koala/realtime_updates.rb
88
112
  - lib/koala/rest_api.rb
@@ -99,6 +123,7 @@ files:
99
123
  - spec/cases/graph_collection_spec.rb
100
124
  - spec/cases/http_service_spec.rb
101
125
  - spec/cases/koala_spec.rb
126
+ - spec/cases/multipart_request_spec.rb
102
127
  - spec/cases/oauth_spec.rb
103
128
  - spec/cases/realtime_updates_spec.rb
104
129
  - spec/cases/rest_api_spec.rb
@@ -117,39 +142,45 @@ files:
117
142
  - spec/support/ordered_hash.rb
118
143
  - spec/support/rest_api_shared_examples.rb
119
144
  - spec/support/uploadable_io_shared_examples.rb
145
+ has_rdoc: true
120
146
  homepage: http://github.com/arsduo/koala
121
147
  licenses: []
148
+
122
149
  post_install_message:
123
- rdoc_options:
150
+ rdoc_options:
124
151
  - --line-numbers
125
152
  - --inline-source
126
153
  - --title
127
154
  - Koala
128
- require_paths:
155
+ require_paths:
129
156
  - lib
130
- required_ruby_version: !ruby/object:Gem::Requirement
157
+ required_ruby_version: !ruby/object:Gem::Requirement
131
158
  none: false
132
- requirements:
133
- - - ! '>='
134
- - !ruby/object:Gem::Version
135
- version: '0'
136
- segments:
159
+ requirements:
160
+ - - ">="
161
+ - !ruby/object:Gem::Version
162
+ hash: 3
163
+ segments:
137
164
  - 0
138
- hash: 2837078681376474267
139
- required_rubygems_version: !ruby/object:Gem::Requirement
165
+ version: "0"
166
+ required_rubygems_version: !ruby/object:Gem::Requirement
140
167
  none: false
141
- requirements:
142
- - - ! '>='
143
- - !ruby/object:Gem::Version
144
- version: '1.2'
168
+ requirements:
169
+ - - ">="
170
+ - !ruby/object:Gem::Version
171
+ hash: 11
172
+ segments:
173
+ - 1
174
+ - 2
175
+ version: "1.2"
145
176
  requirements: []
177
+
146
178
  rubyforge_project:
147
- rubygems_version: 1.8.8
179
+ rubygems_version: 1.5.2
148
180
  signing_key:
149
181
  specification_version: 3
150
- summary: A lightweight, flexible library for Facebook with support for the Graph API,
151
- the REST API, realtime updates, and OAuth authentication.
152
- test_files:
182
+ summary: A lightweight, flexible library for Facebook with support for the Graph API, the REST API, realtime updates, and OAuth authentication.
183
+ test_files:
153
184
  - spec/cases/api_spec.rb
154
185
  - spec/cases/error_spec.rb
155
186
  - spec/cases/graph_and_rest_api_spec.rb
@@ -158,6 +189,7 @@ test_files:
158
189
  - spec/cases/graph_collection_spec.rb
159
190
  - spec/cases/http_service_spec.rb
160
191
  - spec/cases/koala_spec.rb
192
+ - spec/cases/multipart_request_spec.rb
161
193
  - spec/cases/oauth_spec.rb
162
194
  - spec/cases/realtime_updates_spec.rb
163
195
  - spec/cases/rest_api_spec.rb