koala 0.4 → 3.7.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.
- checksums.yaml +7 -0
- data/.github/workflows/test.yml +32 -0
- data/.gitignore +9 -0
- data/.rspec +1 -0
- data/.yardopts +3 -0
- data/Gemfile +25 -0
- data/ISSUE_TEMPLATE +25 -0
- data/LICENSE +22 -0
- data/Manifest +32 -5
- data/PULL_REQUEST_TEMPLATE +11 -0
- data/Rakefile +12 -12
- data/changelog.md +781 -0
- data/code_of_conduct.md +74 -0
- data/koala.gemspec +28 -24
- data/lib/koala/api/batch_operation.rb +86 -0
- data/lib/koala/api/graph_api_methods.rb +504 -0
- data/lib/koala/api/graph_batch_api.rb +167 -0
- data/lib/koala/api/graph_collection.rb +129 -0
- data/lib/koala/api/graph_error_checker.rb +72 -0
- data/lib/koala/api.rb +159 -0
- data/lib/koala/configuration.rb +56 -0
- data/lib/koala/errors.rb +126 -0
- data/lib/koala/http_service/request.rb +133 -0
- data/lib/koala/http_service/response.rb +20 -0
- data/lib/koala/http_service/uploadable_io.rb +183 -0
- data/lib/koala/http_service.rb +108 -0
- data/lib/koala/oauth.rb +342 -0
- data/lib/koala/realtime_updates.rb +151 -0
- data/lib/koala/test_users.rb +189 -0
- data/lib/koala/utils.rb +41 -0
- data/lib/koala/version.rb +3 -0
- data/lib/koala.rb +51 -291
- data/readme.md +269 -21
- data/spec/cases/api_spec.rb +362 -0
- data/spec/cases/configuration_spec.rb +11 -0
- data/spec/cases/error_spec.rb +143 -0
- data/spec/cases/graph_api_batch_spec.rb +788 -0
- data/spec/cases/graph_api_spec.rb +76 -0
- data/spec/cases/graph_collection_spec.rb +192 -0
- data/spec/cases/graph_error_checker_spec.rb +147 -0
- data/spec/cases/http_service/request_spec.rb +250 -0
- data/spec/cases/http_service/response_spec.rb +24 -0
- data/spec/cases/http_service_spec.rb +280 -0
- data/spec/cases/koala_spec.rb +57 -0
- data/spec/cases/koala_test_spec.rb +5 -0
- data/spec/cases/oauth_spec.rb +647 -0
- data/spec/cases/realtime_updates_spec.rb +327 -0
- data/spec/cases/test_users_spec.rb +383 -0
- data/spec/cases/uploadable_io_spec.rb +266 -0
- data/spec/cases/utils_spec.rb +55 -0
- data/spec/fixtures/beach.jpg +0 -0
- data/spec/fixtures/cat.m4v +0 -0
- data/spec/fixtures/facebook_data.yml +63 -0
- data/spec/fixtures/mock_facebook_responses.yml +483 -0
- data/spec/fixtures/vcr_cassettes/app_test_accounts.yml +97 -0
- data/spec/fixtures/vcr_cassettes/friend_list_next_page.yml +121 -0
- data/spec/integration/graph_collection_spec.rb +24 -0
- data/spec/spec_helper.rb +25 -0
- data/spec/support/custom_matchers.rb +28 -0
- data/spec/support/graph_api_shared_examples.rb +534 -0
- data/spec/support/koala_test.rb +251 -0
- data/spec/support/mock_http_service.rb +140 -0
- data/spec/support/uploadable_io_shared_examples.rb +70 -0
- metadata +206 -62
- data/CHANGELOG +0 -24
- data/init.rb +0 -2
- data/lib/http_services.rb +0 -60
- data/test/facebook_data.yml +0 -5
- data/test/koala/facebook_no_access_token_tests.rb +0 -119
- data/test/koala/facebook_with_access_token_tests.rb +0 -106
- data/test/koala_tests.rb +0 -30
metadata
CHANGED
|
@@ -1,80 +1,224 @@
|
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: koala
|
|
3
|
-
version: !ruby/object:Gem::Version
|
|
4
|
-
|
|
5
|
-
segments:
|
|
6
|
-
- 0
|
|
7
|
-
- 4
|
|
8
|
-
version: "0.4"
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 3.7.0
|
|
9
5
|
platform: ruby
|
|
10
|
-
authors:
|
|
11
|
-
- Alex Koppel
|
|
12
|
-
autorequire:
|
|
6
|
+
authors:
|
|
7
|
+
- Alex Koppel
|
|
13
8
|
bindir: bin
|
|
14
9
|
cert_chain: []
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: faraday
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - ">="
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '0'
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - ">="
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '0'
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: faraday-multipart
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - ">="
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '0'
|
|
33
|
+
type: :runtime
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - ">="
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '0'
|
|
40
|
+
- !ruby/object:Gem::Dependency
|
|
41
|
+
name: addressable
|
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - ">="
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '0'
|
|
47
|
+
type: :runtime
|
|
48
|
+
prerelease: false
|
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - ">="
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '0'
|
|
54
|
+
- !ruby/object:Gem::Dependency
|
|
55
|
+
name: json
|
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
|
57
|
+
requirements:
|
|
58
|
+
- - ">="
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: '1.8'
|
|
61
|
+
type: :runtime
|
|
62
|
+
prerelease: false
|
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
64
|
+
requirements:
|
|
65
|
+
- - ">="
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: '1.8'
|
|
68
|
+
- !ruby/object:Gem::Dependency
|
|
69
|
+
name: rexml
|
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
|
71
|
+
requirements:
|
|
72
|
+
- - ">="
|
|
73
|
+
- !ruby/object:Gem::Version
|
|
74
|
+
version: '0'
|
|
75
|
+
type: :runtime
|
|
76
|
+
prerelease: false
|
|
77
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
78
|
+
requirements:
|
|
79
|
+
- - ">="
|
|
80
|
+
- !ruby/object:Gem::Version
|
|
81
|
+
version: '0'
|
|
82
|
+
- !ruby/object:Gem::Dependency
|
|
83
|
+
name: base64
|
|
84
|
+
requirement: !ruby/object:Gem::Requirement
|
|
85
|
+
requirements:
|
|
86
|
+
- - ">="
|
|
87
|
+
- !ruby/object:Gem::Version
|
|
88
|
+
version: '0'
|
|
89
|
+
type: :runtime
|
|
90
|
+
prerelease: false
|
|
91
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
92
|
+
requirements:
|
|
93
|
+
- - ">="
|
|
94
|
+
- !ruby/object:Gem::Version
|
|
95
|
+
version: '0'
|
|
96
|
+
- !ruby/object:Gem::Dependency
|
|
97
|
+
name: ostruct
|
|
98
|
+
requirement: !ruby/object:Gem::Requirement
|
|
99
|
+
requirements:
|
|
100
|
+
- - ">="
|
|
101
|
+
- !ruby/object:Gem::Version
|
|
102
|
+
version: '0'
|
|
103
|
+
type: :runtime
|
|
104
|
+
prerelease: false
|
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
106
|
+
requirements:
|
|
107
|
+
- - ">="
|
|
108
|
+
- !ruby/object:Gem::Version
|
|
109
|
+
version: '0'
|
|
110
|
+
- !ruby/object:Gem::Dependency
|
|
111
|
+
name: cgi
|
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
|
113
|
+
requirements:
|
|
114
|
+
- - ">="
|
|
115
|
+
- !ruby/object:Gem::Version
|
|
116
|
+
version: '0'
|
|
117
|
+
type: :runtime
|
|
118
|
+
prerelease: false
|
|
119
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
120
|
+
requirements:
|
|
121
|
+
- - ">="
|
|
122
|
+
- !ruby/object:Gem::Version
|
|
123
|
+
version: '0'
|
|
124
|
+
description: Koala is a lightweight, flexible Ruby SDK for Facebook. It allows read/write
|
|
125
|
+
access to the social graph via the Graph and REST APIs, as well as support for realtime
|
|
126
|
+
updates and OAuth and Facebook Connect authentication. Koala is fully tested and
|
|
127
|
+
supports Net::HTTP and Typhoeus connections out of the box and can accept custom
|
|
128
|
+
modules for other services.
|
|
21
129
|
email: alex@alexkoppel.com
|
|
22
130
|
executables: []
|
|
23
|
-
|
|
24
131
|
extensions: []
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
-
|
|
28
|
-
|
|
29
|
-
-
|
|
30
|
-
|
|
31
|
-
-
|
|
132
|
+
extra_rdoc_files:
|
|
133
|
+
- changelog.md
|
|
134
|
+
- readme.md
|
|
135
|
+
files:
|
|
136
|
+
- ".github/workflows/test.yml"
|
|
137
|
+
- ".gitignore"
|
|
138
|
+
- ".rspec"
|
|
139
|
+
- ".yardopts"
|
|
140
|
+
- Gemfile
|
|
141
|
+
- ISSUE_TEMPLATE
|
|
142
|
+
- LICENSE
|
|
32
143
|
- Manifest
|
|
144
|
+
- PULL_REQUEST_TEMPLATE
|
|
33
145
|
- Rakefile
|
|
34
|
-
-
|
|
146
|
+
- changelog.md
|
|
147
|
+
- code_of_conduct.md
|
|
35
148
|
- koala.gemspec
|
|
36
|
-
- lib/http_services.rb
|
|
37
149
|
- lib/koala.rb
|
|
150
|
+
- lib/koala/api.rb
|
|
151
|
+
- lib/koala/api/batch_operation.rb
|
|
152
|
+
- lib/koala/api/graph_api_methods.rb
|
|
153
|
+
- lib/koala/api/graph_batch_api.rb
|
|
154
|
+
- lib/koala/api/graph_collection.rb
|
|
155
|
+
- lib/koala/api/graph_error_checker.rb
|
|
156
|
+
- lib/koala/configuration.rb
|
|
157
|
+
- lib/koala/errors.rb
|
|
158
|
+
- lib/koala/http_service.rb
|
|
159
|
+
- lib/koala/http_service/request.rb
|
|
160
|
+
- lib/koala/http_service/response.rb
|
|
161
|
+
- lib/koala/http_service/uploadable_io.rb
|
|
162
|
+
- lib/koala/oauth.rb
|
|
163
|
+
- lib/koala/realtime_updates.rb
|
|
164
|
+
- lib/koala/test_users.rb
|
|
165
|
+
- lib/koala/utils.rb
|
|
166
|
+
- lib/koala/version.rb
|
|
38
167
|
- readme.md
|
|
39
|
-
-
|
|
40
|
-
-
|
|
41
|
-
-
|
|
42
|
-
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
-
|
|
50
|
-
-
|
|
51
|
-
-
|
|
168
|
+
- spec/cases/api_spec.rb
|
|
169
|
+
- spec/cases/configuration_spec.rb
|
|
170
|
+
- spec/cases/error_spec.rb
|
|
171
|
+
- spec/cases/graph_api_batch_spec.rb
|
|
172
|
+
- spec/cases/graph_api_spec.rb
|
|
173
|
+
- spec/cases/graph_collection_spec.rb
|
|
174
|
+
- spec/cases/graph_error_checker_spec.rb
|
|
175
|
+
- spec/cases/http_service/request_spec.rb
|
|
176
|
+
- spec/cases/http_service/response_spec.rb
|
|
177
|
+
- spec/cases/http_service_spec.rb
|
|
178
|
+
- spec/cases/koala_spec.rb
|
|
179
|
+
- spec/cases/koala_test_spec.rb
|
|
180
|
+
- spec/cases/oauth_spec.rb
|
|
181
|
+
- spec/cases/realtime_updates_spec.rb
|
|
182
|
+
- spec/cases/test_users_spec.rb
|
|
183
|
+
- spec/cases/uploadable_io_spec.rb
|
|
184
|
+
- spec/cases/utils_spec.rb
|
|
185
|
+
- spec/fixtures/beach.jpg
|
|
186
|
+
- spec/fixtures/cat.m4v
|
|
187
|
+
- spec/fixtures/facebook_data.yml
|
|
188
|
+
- spec/fixtures/mock_facebook_responses.yml
|
|
189
|
+
- spec/fixtures/vcr_cassettes/app_test_accounts.yml
|
|
190
|
+
- spec/fixtures/vcr_cassettes/friend_list_next_page.yml
|
|
191
|
+
- spec/integration/graph_collection_spec.rb
|
|
192
|
+
- spec/spec_helper.rb
|
|
193
|
+
- spec/support/custom_matchers.rb
|
|
194
|
+
- spec/support/graph_api_shared_examples.rb
|
|
195
|
+
- spec/support/koala_test.rb
|
|
196
|
+
- spec/support/mock_http_service.rb
|
|
197
|
+
- spec/support/uploadable_io_shared_examples.rb
|
|
198
|
+
homepage: http://github.com/arsduo/koala
|
|
199
|
+
licenses:
|
|
200
|
+
- MIT
|
|
201
|
+
metadata: {}
|
|
202
|
+
rdoc_options:
|
|
203
|
+
- "--line-numbers"
|
|
204
|
+
- "--inline-source"
|
|
205
|
+
- "--title"
|
|
52
206
|
- Koala
|
|
53
|
-
|
|
54
|
-
- readme.md
|
|
55
|
-
require_paths:
|
|
207
|
+
require_paths:
|
|
56
208
|
- lib
|
|
57
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
|
58
|
-
requirements:
|
|
209
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
210
|
+
requirements:
|
|
59
211
|
- - ">="
|
|
60
|
-
- !ruby/object:Gem::Version
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
65
|
-
requirements:
|
|
212
|
+
- !ruby/object:Gem::Version
|
|
213
|
+
version: '2.1'
|
|
214
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
215
|
+
requirements:
|
|
66
216
|
- - ">="
|
|
67
|
-
- !ruby/object:Gem::Version
|
|
68
|
-
|
|
69
|
-
- 1
|
|
70
|
-
- 2
|
|
71
|
-
version: "1.2"
|
|
217
|
+
- !ruby/object:Gem::Version
|
|
218
|
+
version: '0'
|
|
72
219
|
requirements: []
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
specification_version: 3
|
|
78
|
-
summary: A lightweight, flexible library for Facebook's new Graph API
|
|
220
|
+
rubygems_version: 3.8.0.dev
|
|
221
|
+
specification_version: 4
|
|
222
|
+
summary: A lightweight, flexible library for Facebook with support for the Graph API,
|
|
223
|
+
the REST API, realtime updates, and OAuth authentication.
|
|
79
224
|
test_files: []
|
|
80
|
-
|
data/CHANGELOG
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
v0.4.0
|
|
2
|
-
-- Adopted the Koala name
|
|
3
|
-
-- Fixed cookie verification bug for non-expiring OAuth tokens
|
|
4
|
-
|
|
5
|
-
v0.3.1
|
|
6
|
-
-- Bug fixes.
|
|
7
|
-
|
|
8
|
-
v0.3
|
|
9
|
-
-- Renamed Graph API class from Facebook::GraphAPI to FacebookGraph::API
|
|
10
|
-
-- Created FacebookGraph::OAuth class for tokens and OAuth URLs
|
|
11
|
-
-- Updated method for including HTTP service (think we've got it this time)
|
|
12
|
-
-- Updated tests
|
|
13
|
-
-- Added CHANGELOG and gemspec
|
|
14
|
-
|
|
15
|
-
v0.2
|
|
16
|
-
-- Gemified the project
|
|
17
|
-
-- Split out HTTP services into their own file, and adjusted inclusion method
|
|
18
|
-
|
|
19
|
-
v0.1
|
|
20
|
-
-- Added modular support for Typhoeus
|
|
21
|
-
-- Added tests
|
|
22
|
-
|
|
23
|
-
v0.0
|
|
24
|
-
-- Hi from F8! Basic read/write from the graph is working
|
data/init.rb
DELETED
data/lib/http_services.rb
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
module Koala
|
|
2
|
-
class GraphAPI
|
|
3
|
-
module NetHTTPService
|
|
4
|
-
# this service uses Net::HTTP to send requests to the graph
|
|
5
|
-
def self.included(base)
|
|
6
|
-
base.class_eval do
|
|
7
|
-
require 'net/http' unless defined?(Net::HTTP)
|
|
8
|
-
require 'net/https'
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def make_request(path, args, verb)
|
|
13
|
-
# We translate args to a valid query string. If post is specified,
|
|
14
|
-
# we send a POST request to the given path with the given arguments.
|
|
15
|
-
|
|
16
|
-
# if the verb isn't get or post, send it as a post argument
|
|
17
|
-
args.merge!({:method => verb}) && verb = "post" if verb != "get" && verb != "post"
|
|
18
|
-
|
|
19
|
-
http = Net::HTTP.new(FACEBOOK_GRAPH_SERVER, 443)
|
|
20
|
-
http.use_ssl = true
|
|
21
|
-
# we turn off certificate validation to avoid the
|
|
22
|
-
# "warning: peer certificate won't be verified in this SSL session" warning
|
|
23
|
-
# not sure if this is the right way to handle it
|
|
24
|
-
# see http://redcorundum.blogspot.com/2008/03/ssl-certificates-and-nethttps.html
|
|
25
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
|
26
|
-
|
|
27
|
-
result = http.start { |http|
|
|
28
|
-
response, body = (verb == "post" ? http.post(path, encode_params(args)) : http.get("#{path}?#{encode_params(args)}"))
|
|
29
|
-
body
|
|
30
|
-
}
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
protected
|
|
34
|
-
def encode_params(param_hash)
|
|
35
|
-
# TODO investigating whether a built-in method handles this
|
|
36
|
-
# if no hash (e.g. no auth token) return empty string
|
|
37
|
-
((param_hash || {}).collect do |key_and_value|
|
|
38
|
-
key_and_value[1] = key_and_value[1].to_json if key_and_value[1].class != String
|
|
39
|
-
"#{key_and_value[0].to_s}=#{CGI.escape key_and_value[1]}"
|
|
40
|
-
end).join("&")
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
module TyphoeusService
|
|
45
|
-
# this service uses Typhoeus to send requests to the graph
|
|
46
|
-
def self.included(base)
|
|
47
|
-
base.class_eval do
|
|
48
|
-
require 'typhoeus' unless defined?(Typhoeus)
|
|
49
|
-
include Typhoeus
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def make_request(path, args, verb)
|
|
54
|
-
# if the verb isn't get or post, send it as a post argument
|
|
55
|
-
args.merge!({:method => verb}) && verb = "post" if verb != "get" && verb != "post"
|
|
56
|
-
self.class.send(verb, "https://#{FACEBOOK_GRAPH_SERVER}/#{path}", :params => args).body
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
end
|
data/test/facebook_data.yml
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
class FacebookNoAccessTokenTests < Test::Unit::TestCase
|
|
2
|
-
describe "Koala GraphAPI without an access token" do
|
|
3
|
-
before :each do
|
|
4
|
-
@graph = Koala::GraphAPI.new
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
it "should get public data about a user" do
|
|
8
|
-
result = @graph.get_object("koppel")
|
|
9
|
-
# the results should have an ID and a name, among other things
|
|
10
|
-
(result["id"] && result["name"]).should
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
it "should not get private data about a user" do
|
|
14
|
-
result = @graph.get_object("koppel")
|
|
15
|
-
# updated_time should be a pretty fixed test case
|
|
16
|
-
result["updated_time"].should be_nil
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
it "should get public data about a Page" do
|
|
21
|
-
result = @graph.get_object("contextoptional")
|
|
22
|
-
# the results should have an ID and a name, among other things
|
|
23
|
-
(result["id"] && result["name"]).should
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
it "should not be able to get data about 'me'" do
|
|
27
|
-
begin
|
|
28
|
-
@graph.get_object("me")
|
|
29
|
-
rescue Koala::GraphAPIError => @right_err
|
|
30
|
-
rescue Exception => wrong_err
|
|
31
|
-
end
|
|
32
|
-
@right_err.should_not be_nil
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
it "should be able to get multiple objects" do
|
|
36
|
-
results = @graph.get_objects(["contextoptional", "naitik"])
|
|
37
|
-
results.length.should == 2
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
it "shouldn't be able to access connections from users" do
|
|
41
|
-
begin
|
|
42
|
-
@graph.get_connections("lukeshepard", "likes")
|
|
43
|
-
rescue Koala::GraphAPIError => @right_err
|
|
44
|
-
rescue Exception => wrong_err
|
|
45
|
-
end
|
|
46
|
-
@right_err.should_not be_nil
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
it "should be able to access connections from public Pages" do
|
|
50
|
-
result = @graph.get_connections("contextoptional", "likes")
|
|
51
|
-
result["data"].should be_a(Array)
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
it "should not be able to put an object" do
|
|
55
|
-
begin
|
|
56
|
-
@result = @graph.put_object("lukeshepard", "feed", :message => "Hello, world")
|
|
57
|
-
rescue Koala::GraphAPIError => @right_err
|
|
58
|
-
rescue Exception => wrong_err
|
|
59
|
-
end
|
|
60
|
-
@right_err.should_not be_nil
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
# these are not strictly necessary as the other put methods resolve to put_object, but are here for completeness
|
|
64
|
-
it "should not be able to post to a feed" do
|
|
65
|
-
begin
|
|
66
|
-
@result = @graph.put_wall_post("Hello, world", {:name => "Context Optional", :link => "http://www.contextoptional.com/"}, "contextoptional")
|
|
67
|
-
rescue Koala::GraphAPIError => @right_err
|
|
68
|
-
rescue Exception => wrong_err
|
|
69
|
-
end
|
|
70
|
-
@right_err.should_not be_nil
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
it "should not be able to comment on an object" do
|
|
74
|
-
begin
|
|
75
|
-
# random public post on the ContextOptional wall
|
|
76
|
-
@result = @graph.put_comment("7204941866_119776748033392", "The hackathon was great!")
|
|
77
|
-
rescue Koala::GraphAPIError => @right_err
|
|
78
|
-
rescue Exception => wrong_err
|
|
79
|
-
end
|
|
80
|
-
@right_err.should_not be_nil
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
it "should not be able to like an object" do
|
|
84
|
-
begin
|
|
85
|
-
@result = @graph.put_like("7204941866_119776748033392")
|
|
86
|
-
rescue Koala::GraphAPIError => @right_err
|
|
87
|
-
rescue Exception => wrong_err
|
|
88
|
-
end
|
|
89
|
-
@right_err.should_not be_nil
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
# DELETE
|
|
94
|
-
it "should not be able to delete posts" do
|
|
95
|
-
begin
|
|
96
|
-
# test post on the Ruby SDK Test application
|
|
97
|
-
@result = @graph.delete_object("115349521819193_113815981982767")
|
|
98
|
-
rescue Koala::GraphAPIError => @right_err
|
|
99
|
-
rescue Exception => wrong_err
|
|
100
|
-
end
|
|
101
|
-
@right_err.should_not be_nil
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
# SEARCH
|
|
105
|
-
it "should be able to search" do
|
|
106
|
-
result = @graph.search("facebook")
|
|
107
|
-
result["data"].should be_an(Array)
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
# REQUEST
|
|
111
|
-
# the above tests test this already, but we should do it explicitly
|
|
112
|
-
it "should be able to send get-only requests" do
|
|
113
|
-
# to be written
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
end # describe
|
|
117
|
-
|
|
118
|
-
end #class
|
|
119
|
-
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
class FacebookWithAccessTokenTests < Test::Unit::TestCase
|
|
2
|
-
describe "Koala GraphAPI with an access token" do
|
|
3
|
-
before :each do
|
|
4
|
-
token = $testing_data["oauth_token"]
|
|
5
|
-
raise Exception, "Must supply access token to run FacebookWithAccessTokenTests!" unless token
|
|
6
|
-
@graph = Koala::GraphAPI.new(token)
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
after :each do
|
|
10
|
-
# clean up any temporary objects
|
|
11
|
-
if @temporary_object_id
|
|
12
|
-
puts "\nCleaning up temporary object #{@temporary_object_id.to_s}"
|
|
13
|
-
@graph.delete_object(@temporary_object_id)
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
it "should get public data about a user" do
|
|
18
|
-
result = @graph.get_object("koppel")
|
|
19
|
-
# the results should have an ID and a name, among other things
|
|
20
|
-
(result["id"] && result["name"]).should_not be_nil
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
it "should get private data about a user" do
|
|
24
|
-
result = @graph.get_object("koppel")
|
|
25
|
-
# updated_time should be a pretty fixed test case
|
|
26
|
-
result["updated_time"].should_not be_nil
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
it "should get public data about a Page" do
|
|
30
|
-
result = @graph.get_object("contextoptional")
|
|
31
|
-
# the results should have an ID and a name, among other things
|
|
32
|
-
(result["id"] && result["name"]).should
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
it "should get data about 'me'" do
|
|
36
|
-
result = @graph.get_object("me")
|
|
37
|
-
result["updated_time"].should
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
it "should be able to get multiple objects" do
|
|
41
|
-
result = @graph.get_objects(["contextoptional", "naitik"])
|
|
42
|
-
result.length.should == 2
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
it "should be able to access connections from users" do
|
|
46
|
-
result = @graph.get_connections("lukeshepard", "likes")
|
|
47
|
-
result["data"].length.should > 0
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
it "should be able to access connections from public Pages" do
|
|
51
|
-
result = @graph.get_connections("contextoptional", "likes")
|
|
52
|
-
result["data"].should be_a(Array)
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
# PUT
|
|
56
|
-
it "should be able to put an object" do
|
|
57
|
-
result = @graph.put_wall_post("Hello, world, from the test suite!")
|
|
58
|
-
@temporary_object_id = result["id"]
|
|
59
|
-
@temporary_object_id.should_not be_nil
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
# DELETE
|
|
63
|
-
it "should not be able to delete posts" do
|
|
64
|
-
result = @graph.put_wall_post("Hello, world, from the test suite delete method!")
|
|
65
|
-
object_id_to_delete = result["id"]
|
|
66
|
-
delete_result = @graph.delete_object(object_id_to_delete)
|
|
67
|
-
delete_result.should == true
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
# these are not strictly necessary as the other put methods resolve to put_object, but are here for completeness
|
|
71
|
-
it "should be able to post to a feed" do
|
|
72
|
-
result = @graph.put_wall_post("Hello, world, from the test suite again!", {:name => "Context Optional", :link => "http://www.contextoptional.com/"})
|
|
73
|
-
@temporary_object_id = result["id"]
|
|
74
|
-
@temporary_object_id.should_not be_nil
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
it "should be able to comment on an object" do
|
|
78
|
-
result = @graph.put_wall_post("Hello, world, from the test suite, testing comments!")
|
|
79
|
-
@temporary_object_id = result["id"]
|
|
80
|
-
|
|
81
|
-
# this will be deleted when the post gets deleted
|
|
82
|
-
comment_result = @graph.put_comment(@temporary_object_id, "it's my comment!")
|
|
83
|
-
comment_result.should_not be_nil
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
it "should be able to like an object" do
|
|
87
|
-
result = @graph.put_wall_post("Hello, world, from the test suite, testing comments!")
|
|
88
|
-
@temporary_object_id = result["id"]
|
|
89
|
-
like_result = @graph.put_like(@temporary_object_id)
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
# SEARCH
|
|
93
|
-
it "should be able to search" do
|
|
94
|
-
result = @graph.search("facebook")
|
|
95
|
-
result["data"].should be_an(Array)
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
# REQUEST
|
|
99
|
-
# the above tests test this already, but we should do it explicitly
|
|
100
|
-
it "should be able to send get and put requests" do
|
|
101
|
-
# to be written
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
end # describe
|
|
105
|
-
|
|
106
|
-
end #class
|
data/test/koala_tests.rb
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
puts __FILE__
|
|
2
|
-
require 'test/unit'
|
|
3
|
-
require 'rubygems'
|
|
4
|
-
require 'spec/test/unit'
|
|
5
|
-
|
|
6
|
-
require 'koala'
|
|
7
|
-
require 'koala/facebook_no_access_token_tests'
|
|
8
|
-
require 'koala/facebook_with_access_token_tests'
|
|
9
|
-
|
|
10
|
-
class FacebookTestSuite
|
|
11
|
-
def self.suite
|
|
12
|
-
suite = Test::Unit::TestSuite.new
|
|
13
|
-
suite << FacebookNoAccessTokenTests.suite
|
|
14
|
-
suite << FacebookWithAccessTokenTests.suite
|
|
15
|
-
#suite << FacebookCookieTest.suite
|
|
16
|
-
suite
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
# load testing data (see note in readme.md)
|
|
21
|
-
# I'm seeing a bug with spec and gets where the facebook_test_suite.rb file gets read in when gets is called
|
|
22
|
-
# until that's solved, we'll need to store/update tokens in the access_token file
|
|
23
|
-
$testing_data = YAML.load_file("facebook_data.yml") rescue {}
|
|
24
|
-
|
|
25
|
-
unless $testing_data["oauth_token"]
|
|
26
|
-
puts "Access token tests will fail until you store a valid token in facebook_data.yml"
|
|
27
|
-
end
|
|
28
|
-
unless cookies = $testing_data["cookie_hash"]
|
|
29
|
-
puts "Cookie tests will fail until you store a valid token in facebook_data.yml"
|
|
30
|
-
end
|