koala 0.6.0 → 0.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.
@@ -0,0 +1,36 @@
1
+ shared_examples_for "Koala RestAPI with an access token" do
2
+ # FQL
3
+ it "should be able to access public information via FQL" do
4
+ result = @api.fql_query('select first_name from user where uid = 216743')
5
+ result.size.should == 1
6
+ result.first['first_name'].should == 'Chris'
7
+ end
8
+
9
+ it "should be able to access protected information via FQL" do
10
+ # Tests agains the permissions fql table
11
+
12
+ # get the current user's ID
13
+ # we're sneakily using the Graph API, which should be okay since it has its own tests
14
+ g = Koala::Facebook::GraphAPI.new(@token)
15
+ id = g.get_object("me", :fields => "id")["id"]
16
+
17
+ # now send a query about your permissions
18
+ result = @api.fql_query("select read_stream from permissions where uid = #{id}")
19
+
20
+ result.size.should == 1
21
+ # we assume that you have read_stream permissions, so we can test against that
22
+ # (should we keep this?)
23
+ result.first["read_stream"].should == 1
24
+ end
25
+ end
26
+
27
+ class FacebookRestAPIWithAccessTokenTests < Test::Unit::TestCase
28
+ describe "Koala RestAPI with an access token" do
29
+ it_should_behave_like "live testing examples"
30
+ it_should_behave_like "Koala RestAPI with an access token"
31
+
32
+ before :each do
33
+ @api = Koala::Facebook::RestAPI.new(@token)
34
+ end
35
+ end
36
+ end
data/spec/koala_spec.rb CHANGED
@@ -1,38 +1,18 @@
1
- require 'test/unit'
2
- require 'rubygems'
3
- require 'spec/test/unit'
4
-
5
- # load the libraries
6
- require 'koala'
7
-
8
- # load the tests
9
- require 'koala/facebook_no_access_token_tests'
10
- require 'koala/facebook_with_access_token_tests'
11
- require 'koala/facebook_oauth_tests'
12
- require 'koala/facebook_rest_api_with_access_token_test'
13
- require 'koala/facebook_rest_api_no_access_token_test'
14
-
15
- class FacebookTestSuite
16
- def self.suite
17
- suite = Test::Unit::TestSuite.new
18
- suite << FacebookNoAccessTokenTests.suite
19
- suite << FacebookWithAccessTokenTests.suite
20
- suite << FacebookOAuthTests.suite
21
- suite << FacebookRestAPIWithAccessTokenTests.suite
22
- suite << FacebookRestAPINoAccessTokenTest.suite
23
- suite
24
- end
25
- end
26
-
27
- # load testing data (see note in readme.md)
28
- # I'm seeing a bug with spec and gets where the facebook_test_suite.rb file gets read in when gets is called
29
- # until that's solved, we'll need to store/update tokens in the access_token file
30
- $testing_data = YAML.load_file("facebook_data.yml") rescue {}
31
-
32
- unless $testing_data["oauth_token"]
33
- puts "Access token tests will fail until you store a valid token in facebook_data.yml"
34
- end
35
-
36
- unless $testing_data["oauth_test_data"] && $testing_data["oauth_test_data"]["code"] && $testing_data["oauth_test_data"]["secret"]
37
- puts "Cookie tests will fail until you store valid data for the cookie hash, app_id, and app secret in facebook_data.yml"
38
- end
1
+ require 'koala_spec_helper'
2
+ require 'mock_http_service'
3
+
4
+ # Runs Koala specs using stubs for HTTP requests
5
+ #
6
+ # Valid OAuth token and code are not necessary to run these
7
+ # specs. Because of this, specs do not fail due to Facebook
8
+ # imposed rate-limits or server timeouts.
9
+ #
10
+ # However as a result they are more brittle since
11
+ # we are not testing the latest responses from the Facebook servers.
12
+ # Therefore, to be certain all specs pass with the current
13
+ # Facebook services, run koala_spec_without_mocks.rb.
14
+
15
+
16
+ Koala.http_service = Koala::MockHTTPService
17
+
18
+ $testing_data = Koala::MockHTTPService::TEST_DATA
@@ -0,0 +1,30 @@
1
+ require 'test/unit'
2
+ require 'rubygems'
3
+ require 'spec/test/unit'
4
+
5
+ # load the libraries
6
+ require 'koala'
7
+
8
+ # load testing data libraries
9
+ require 'koala/live_testing_data_helper'
10
+
11
+ # API tests
12
+ require 'koala/api_base_tests'
13
+
14
+ require 'koala/graph_api/graph_api_no_access_token_tests'
15
+ require 'koala/graph_api/graph_api_with_access_token_tests'
16
+
17
+ require 'koala/rest_api/rest_api_no_access_token_tests'
18
+ require 'koala/rest_api/rest_api_with_access_token_tests'
19
+
20
+ require 'koala/graph_and_rest_api/graph_and_rest_api_no_token_tests'
21
+ require 'koala/graph_and_rest_api/graph_and_rest_api_with_token_tests'
22
+
23
+ # OAuth tests
24
+ require 'koala/oauth/oauth_tests'
25
+
26
+ # Subscriptions tests
27
+ require 'koala/realtime_updates/realtime_updates_tests'
28
+
29
+ # Services tests
30
+ require 'koala/net_http_service_tests'
@@ -0,0 +1,19 @@
1
+ require 'koala_spec_helper'
2
+
3
+ # Runs Koala specs through the Facebook servers
4
+ #
5
+ # Note that you need a valid OAuth token and code for these
6
+ # specs to run. See facebook_data.yml for more information.
7
+
8
+ # load testing data (see note in readme.md)
9
+ # I'm seeing a bug with spec and gets where the facebook_test_suite.rb file gets read in when gets is called
10
+ # until that's solved, we'll need to store/update tokens in the access_token file
11
+ $testing_data = YAML.load_file(File.join(File.dirname(__FILE__), 'facebook_data.yml')) rescue {}
12
+
13
+ unless $testing_data["oauth_token"]
14
+ puts "Access token tests will fail until you store a valid token in facebook_data.yml"
15
+ end
16
+
17
+ unless $testing_data["oauth_test_data"] && $testing_data["oauth_test_data"]["code"] && $testing_data["oauth_test_data"]["secret"]
18
+ puts "Cookie tests will fail until you store valid data for the cookie hash, app_id, and app secret in facebook_data.yml"
19
+ end
@@ -0,0 +1,208 @@
1
+ # Responses by MockHTTPService are taken directly from
2
+ # this file.
3
+ #
4
+ # Structure
5
+ # ----------
6
+ #
7
+ # path:
8
+ # arguments: # sorted by key
9
+ # method: # HTTP method (GET, POST, DELETE, etc.)
10
+ # with_token:
11
+ # no_token:
12
+
13
+ # ====== REST API =====
14
+ rest_api:
15
+
16
+ # -- Stubbed Responses --
17
+ method/fql.query:
18
+ query=select first_name from user where uid = 216743:
19
+ get:
20
+ no_token: '[{"first_name":"Chris"}]'
21
+ with_token: '[{"first_name":"Chris"}]'
22
+ query=select read_stream from permissions where uid = 216743:
23
+ get:
24
+ with_token: '[{"read_stream":1}]'
25
+ no_token: '{"error_code":104,"error_msg":"Requires valid signature","request_args":[{"key":"method","value":"fql.query"},{"key":"format","value":"json"},{"key":"query","value":"select read_stream from permissions where uid = 216743"}]}'
26
+
27
+
28
+ # ====== GRAPH API =====
29
+ graph_api:
30
+
31
+ # -- Common Responses --
32
+
33
+ # Error responses for when a token is required, but not given
34
+ token_required_responses: &token_required
35
+ no_token: '{"error":{"type":"OAuthAccessTokenException", "message":"An access token is required to request this resource."}}'
36
+
37
+ # Common mock item responses
38
+ item_deleted: &item_deleted
39
+ delete:
40
+ with_token: 'true'
41
+
42
+ # OAuth error response
43
+ oauth_error: &oauth_error
44
+ no_token: '{"error": {"type": "OAuthException", "message": "Error validating verification code."}}'
45
+
46
+ # Subscription error response
47
+ verification_error: &verification_error
48
+ with_token: '{"error": {"type": "OAuthException", "message": "Error validating verification code."}}'
49
+
50
+ # -- Stubbed Responses --
51
+ root:
52
+ ids=contextoptional,naitik:
53
+ get:
54
+ with_token: '[{}, {}]'
55
+ no_token: '[{}, {}]'
56
+ me:
57
+ no_args:
58
+ get:
59
+ <<: *token_required
60
+ with_token: '{"updated_time": 1}'
61
+ fields=id:
62
+ get:
63
+ with_token: '{"id": "216743"}'
64
+
65
+ me/feed:
66
+ message=Hello, world, from the test suite!:
67
+ post:
68
+ with_token: '{"id": "MOCK_FEED_ITEM"}'
69
+ message=Hello, world, from the test suite, testing comments!:
70
+ post:
71
+ with_token: '{"id": "MOCK_FEED_ITEM"}'
72
+ message=the cats are asleep:
73
+ post:
74
+ with_token: '{"id": "FEED_ITEM_CATS"}'
75
+ message=Hello, world, from the test suite delete method!:
76
+ post:
77
+ with_token: '{"id": "FEED_ITEM_DELETE"}'
78
+ link=http://www.contextoptional.com/&message=Hello, world, from the test suite again!&name=Context Optional:
79
+ post:
80
+ with_token: '{"id": "FEED_ITEM_CONTEXT"}'
81
+
82
+ koppel:
83
+ no_args:
84
+ get:
85
+ with_token: '{"id": 1, "name": 1, "updated_time": 1}'
86
+ no_token: '{"id": 1, "name": 1}'
87
+
88
+ contextoptional:
89
+ no_args:
90
+ get:
91
+ with_token: '{"id": 1, "name": 1}'
92
+ no_token: '{"id": 1, "name": 1}'
93
+
94
+ contextoptional/likes:
95
+ no_args:
96
+ get:
97
+ with_token: '{"data": [{}]}'
98
+ no_token: '{"data": [{}]}'
99
+
100
+ lukeshepard/likes:
101
+ no_args:
102
+ get:
103
+ <<: *token_required
104
+ with_token: '{"data": [{}]}'
105
+
106
+ chris.baclig/picture:
107
+ no_args:
108
+ get:
109
+ no_token:
110
+ code: 302
111
+ headers:
112
+ Location: http://facebook.com/
113
+ with_token:
114
+ code: 302
115
+ headers:
116
+ Location: http://facebook.com/
117
+ search:
118
+ q=facebook:
119
+ get:
120
+ with_token: '{"data": [{"id": "507731521_100412693339488"}]}'
121
+ no_token: '{"data": [{"id": "507731521_100412693339488"}]}'
122
+
123
+ '115349521819193_113815981982767':
124
+ no_args:
125
+ delete:
126
+ <<: *token_required
127
+
128
+ # -- OAuth responses --
129
+ oauth/access_token:
130
+ client_id=<%= APP_ID %>&client_secret=<%= SECRET %>&code=<%= OAUTH_CODE %>&redirect_uri=<%= OAUTH_DATA["callback_url"] %>:
131
+ get:
132
+ no_token: access_token=<%= ACCESS_TOKEN %>
133
+ client_id=<%= APP_ID %>&client_secret=<%= SECRET %>&code=foo&redirect_uri=<%= OAUTH_DATA["callback_url"] %>:
134
+ get:
135
+ <<: *oauth_error
136
+ client_id=<%= APP_ID %>&client_secret=<%= SECRET %>&type=client_cred:
137
+ post:
138
+ no_token: access_token=<%= ACCESS_TOKEN %>
139
+
140
+
141
+ # -- Subscription Responses --
142
+ <%= APP_ID %>/subscriptions:
143
+ callback_url=<%= SUBSCRIPTION_DATA["subscription_path"] %>&fields=name&object=user&verify_token=<%= SUBSCRIPTION_DATA["verify_token"] %>:
144
+ post:
145
+ with_token:
146
+ code: 200
147
+ callback_url=<%= SUBSCRIPTION_DATA["subscription_path"] %>foo&fields=name&object=user&verify_token=<%= SUBSCRIPTION_DATA["verify_token"] %>:
148
+ post:
149
+ with_token: '{"error":{"type":"Exception","message":"(#2200) subscription validation failed"}}'
150
+ callback_url=foo&fields=name&object=user&verify_token=<%= SUBSCRIPTION_DATA["verify_token"] %>:
151
+ post:
152
+ with_token: '{"error":{"type":"Exception","message":"(#100) callback_url URL is not properly formatted"}}'
153
+ object=user:
154
+ delete:
155
+ with_token:
156
+ code: 200
157
+ object=kittens:
158
+ delete:
159
+ with_token: '{"error":{"type":"Exception","message":"(#100) Invalid parameter"}}'
160
+ no_args:
161
+ delete:
162
+ with_token:
163
+ code: 200
164
+ get:
165
+ with_token: '{"data":[{"callback_url":"http://oauth.twoalex.com/subscriptions", "fields":["name"], "object":"user", "active":true}]}'
166
+
167
+
168
+ callback_url=<%= SUBSCRIPTION_DATA["subscription_path"] %>:
169
+ get:
170
+ with_token: '{"data":[{"callback_url":"http://oauth.twoalex.com/subscriptions", "fields":["name"], "object":"user", "active":true}]}'
171
+
172
+ # -- Mock Item Responses --
173
+
174
+ MOCK_FEED_ITEM/likes:
175
+ no_args:
176
+ post:
177
+ with_token: '{"id": "MOCK_LIKE"}'
178
+
179
+ MOCK_FEED_ITEM/comments:
180
+ message=it's my comment!:
181
+ post:
182
+ with_token: '{"id": "MOCK_COMMENT"}'
183
+
184
+ MOCK_FEED_ITEM:
185
+ no_args:
186
+ <<: *item_deleted
187
+
188
+ FEED_ITEM_CONTEXT:
189
+ no_args:
190
+ <<: *item_deleted
191
+ get:
192
+ with_token: '{"link":"http://www.contextoptional.com/", "name": "Context Optional"}'
193
+
194
+ FEED_ITEM_CATS:
195
+ no_args:
196
+ <<: *item_deleted
197
+ get:
198
+ with_token: '{"message": "the cats are asleep"}'
199
+
200
+ FEED_ITEM_DELETE:
201
+ no_args:
202
+ <<: *item_deleted
203
+
204
+ MOCK_COMMENT:
205
+ no_args:
206
+ <<: *item_deleted
207
+ get:
208
+ with_token: "{\"message\": \"it\'s my comment!\"}"
@@ -0,0 +1,76 @@
1
+ require 'erb'
2
+
3
+ module Koala
4
+ module MockHTTPService
5
+ # Mocks all HTTP requests for with koala_spec_with_mocks.rb
6
+
7
+ # Mocked values to be included in TEST_DATA used in specs
8
+ ACCESS_TOKEN = '*'
9
+ OAUTH_CODE = 'OAUTHCODE'
10
+
11
+ # Loads testing data
12
+ TEST_DATA = YAML.load_file(File.join(File.dirname(__FILE__), 'facebook_data.yml'))
13
+ TEST_DATA.merge!('oauth_token' => Koala::MockHTTPService::ACCESS_TOKEN)
14
+ TEST_DATA['oauth_test_data'].merge!('code' => Koala::MockHTTPService::OAUTH_CODE)
15
+
16
+ # Useful in mock_facebook_responses.yml
17
+ OAUTH_DATA = TEST_DATA['oauth_test_data']
18
+ OAUTH_DATA.merge!('app_access_token' => Koala::MockHTTPService::ACCESS_TOKEN)
19
+ APP_ID = OAUTH_DATA['app_id']
20
+ SECRET = OAUTH_DATA['secret']
21
+ SUBSCRIPTION_DATA = TEST_DATA["subscription_test_data"]
22
+
23
+ # Loads the mock response data via ERB to substitue values for TEST_DATA (see oauth/access_token)
24
+ mock_response_file_path = File.join(File.dirname(__FILE__), 'mock_facebook_responses.yml')
25
+ RESPONSES = YAML.load(ERB.new(IO.read(mock_response_file_path)).result(binding))
26
+
27
+ def self.included(base)
28
+ base.class_eval do
29
+
30
+ def self.make_request(path, args, verb, options = {})
31
+ path = 'root' if path == ''
32
+ verb ||= 'get'
33
+ server = options[:rest_api] ? 'rest_api' : 'graph_api'
34
+ with_token = args.delete('access_token') == ACCESS_TOKEN ? 'with_token' : 'no_token'
35
+
36
+ # Assume format is always JSON
37
+ args.delete('format')
38
+
39
+ # Create a hash key for the arguments
40
+ args = args.empty? ? 'no_args' : args.sort{|a,b| a[0].to_s <=> b[0].to_s }.map{|arr| arr.join('=')}.join('&')
41
+
42
+ begin
43
+ response = RESPONSES[server][path][args][verb][with_token]
44
+
45
+ # Raises an error of with_token/no_token key is missing
46
+ raise NoMethodError unless response
47
+
48
+ # create response class object
49
+ response_object = if response.is_a? String
50
+ Koala::Response.new(200, response, {})
51
+ else
52
+ Koala::Response.new(response["code"] || 200, response["body"] || "", response["headers"] || {})
53
+ end
54
+
55
+ rescue NoMethodError
56
+ # Raises an error message with the place in the data YML
57
+ # to place a mock as well as a URL to request from
58
+ # Facebook's servers for the actual data
59
+ # (Don't forget to replace ACCESS_TOKEN with a real access token)
60
+
61
+ data_trace = [server, path, args, verb, with_token] * ': '
62
+
63
+ args = args == 'no_args' ? '' : "#{args}&"
64
+ args += 'format=json'
65
+ args += "&access_token=#{ACCESS_TOKEN}" if with_token
66
+
67
+ raise "Missing a mock response for #{data_trace}\nAPI PATH: #{[path, args].join('?')}"
68
+ end
69
+
70
+ response_object
71
+ end
72
+
73
+ end # class_eval
74
+ end # included
75
+ end
76
+ end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 6
7
+ - 7
8
8
  - 0
9
- version: 0.6.0
9
+ version: 0.7.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Alex Koppel, Chris Baclig, Rafi Jacoby, Context Optional
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-05-17 00:00:00 -07:00
17
+ date: 2010-05-26 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies: []
20
20
 
@@ -29,6 +29,7 @@ extra_rdoc_files:
29
29
  - lib/graph_api.rb
30
30
  - lib/http_services.rb
31
31
  - lib/koala.rb
32
+ - lib/realtime_updates.rb
32
33
  - lib/rest_api.rb
33
34
  files:
34
35
  - CHANGELOG
@@ -38,15 +39,26 @@ files:
38
39
  - lib/graph_api.rb
39
40
  - lib/http_services.rb
40
41
  - lib/koala.rb
42
+ - lib/realtime_updates.rb
41
43
  - lib/rest_api.rb
42
44
  - readme.md
43
45
  - spec/facebook_data.yml
44
- - spec/koala/facebook_no_access_token_tests.rb
45
- - spec/koala/facebook_oauth_tests.rb
46
- - spec/koala/facebook_rest_api_no_access_token_test.rb
47
- - spec/koala/facebook_rest_api_with_access_token_test.rb
48
- - spec/koala/facebook_with_access_token_tests.rb
46
+ - spec/koala/api_base_tests.rb
47
+ - spec/koala/graph_and_rest_api/graph_and_rest_api_no_token_tests.rb
48
+ - spec/koala/graph_and_rest_api/graph_and_rest_api_with_token_tests.rb
49
+ - spec/koala/graph_api/graph_api_no_access_token_tests.rb
50
+ - spec/koala/graph_api/graph_api_with_access_token_tests.rb
51
+ - spec/koala/live_testing_data_helper.rb
52
+ - spec/koala/net_http_service_tests.rb
53
+ - spec/koala/oauth/oauth_tests.rb
54
+ - spec/koala/realtime_updates/realtime_updates_tests.rb
55
+ - spec/koala/rest_api/rest_api_no_access_token_tests.rb
56
+ - spec/koala/rest_api/rest_api_with_access_token_tests.rb
49
57
  - spec/koala_spec.rb
58
+ - spec/koala_spec_helper.rb
59
+ - spec/koala_spec_without_mocks.rb
60
+ - spec/mock_facebook_responses.yml
61
+ - spec/mock_http_service.rb
50
62
  - koala.gemspec
51
63
  has_rdoc: true
52
64
  homepage: http://github.com/arsduo/koala
@@ -1,88 +0,0 @@
1
- class FacebookNoAccessTokenTests < Test::Unit::TestCase
2
-
3
- describe "Koala GraphAPI without an access token" do
4
- before :each do
5
- @graph = Koala::Facebook::GraphAPI.new
6
- end
7
-
8
- it "should get public data about a user" do
9
- result = @graph.get_object("koppel")
10
- # the results should have an ID and a name, among other things
11
- (result["id"] && result["name"]).should
12
- end
13
-
14
- it "should not get private data about a user" do
15
- result = @graph.get_object("koppel")
16
- # updated_time should be a pretty fixed test case
17
- result["updated_time"].should be_nil
18
- end
19
-
20
-
21
- it "should get public data about a Page" do
22
- result = @graph.get_object("contextoptional")
23
- # the results should have an ID and a name, among other things
24
- (result["id"] && result["name"]).should
25
- end
26
-
27
- it "should not be able to get data about 'me'" do
28
- lambda { @graph.get_object("me") }.should raise_error(Koala::Facebook::APIError)
29
- end
30
-
31
- it "should be able to get multiple objects" do
32
- results = @graph.get_objects(["contextoptional", "naitik"])
33
- results.length.should == 2
34
- end
35
-
36
- it "shouldn't be able to access connections from users" do
37
- lambda { @graph.get_connections("lukeshepard", "likes") }.should raise_error(Koala::Facebook::APIError)
38
- end
39
-
40
- it "should be able to access connections from public Pages" do
41
- result = @graph.get_connections("contextoptional", "likes")
42
- result["data"].should be_a(Array)
43
- end
44
-
45
- it "should not be able to put an object" do
46
- lambda { @result = @graph.put_object("lukeshepard", "feed", :message => "Hello, world") }.should raise_error(Koala::Facebook::APIError)
47
- puts "Error! Object #{@result.inspect} somehow put onto Luke Shepard's wall!" if @result
48
- end
49
-
50
- # these are not strictly necessary as the other put methods resolve to put_object, but are here for completeness
51
- it "should not be able to post to a feed" do
52
- (lambda do
53
- attachment = {:name => "Context Optional", :link => "http://www.contextoptional.com/"}
54
- @result = @graph.put_wall_post("Hello, world", attachment, "contextoptional")
55
- end).should raise_error(Koala::Facebook::APIError)
56
- puts "Error! Object #{@result.inspect} somehow put onto Context Optional's wall!" if @result
57
- end
58
-
59
- it "should not be able to comment on an object" do
60
- # random public post on the ContextOptional wall
61
- lambda { @result = @graph.put_comment("7204941866_119776748033392", "The hackathon was great!") }.should raise_error(Koala::Facebook::APIError)
62
- puts "Error! Object #{@result.inspect} somehow commented on post 7204941866_119776748033392!" if @result
63
- end
64
-
65
- it "should not be able to like an object" do
66
- lambda { @graph.put_like("7204941866_119776748033392") }.should raise_error(Koala::Facebook::APIError)
67
- end
68
-
69
-
70
- # DELETE
71
- it "should not be able to delete posts" do
72
- # test post on the Ruby SDK Test application
73
- lambda { @result = @graph.delete_object("115349521819193_113815981982767") }.should raise_error(Koala::Facebook::APIError)
74
- end
75
-
76
- # SEARCH
77
- it "should be able to search" do
78
- result = @graph.search("facebook")
79
- result["data"].should be_an(Array)
80
- end
81
-
82
- # API
83
- # the above tests test this already, but we should consider additional api tests
84
-
85
- end # describe
86
-
87
- end #class
88
-
@@ -1,20 +0,0 @@
1
- class FacebookRestAPINoAccessTokenTest < Test::Unit::TestCase
2
-
3
- describe "Koala RestAPI without an access token" do
4
- before :each do
5
- @graph = Koala::Facebook::RestAPI.new
6
- end
7
-
8
- # FQL
9
- it "should be able to access public information via FQL" do
10
- @result = @graph.fql_query('select first_name from user where uid = 216743')
11
- @result.size.should == 1
12
- @result.first['first_name'].should == 'Chris'
13
- end
14
-
15
- it "should not be able to access protected information via FQL" do
16
- lambda { @graph.fql_query("select read_stream from permissions where uid = 216743") }.should raise_error(Koala::Facebook::APIError)
17
- end
18
- end
19
-
20
- end
@@ -1,33 +0,0 @@
1
- class FacebookRestAPIWithAccessTokenTests < Test::Unit::TestCase
2
- describe "Koala RestAPI with an access token" do
3
- before :each do
4
- @token = $testing_data["oauth_token"]
5
- raise Exception, "Must supply access token to run FacebookRestAPIWithAccessTokenTests!" unless @token
6
- @rest = Koala::Facebook::RestAPI.new(@token)
7
- end
8
-
9
- # FQL
10
- it "should be able to access public information via FQL" do
11
- result = @rest.fql_query('select first_name from user where uid = 216743')
12
- result.size.should == 1
13
- result.first['first_name'].should == 'Chris'
14
- end
15
-
16
- it "should be able to access protected information via FQL" do
17
- # Tests agains the permissions fql table
18
-
19
- # get the current user's ID
20
- # we're sneakily using the Graph API, which should be okay since it has its own tests
21
- g = Koala::Facebook::GraphAPI.new(@token)
22
- id = g.get_object("me", :fields => "id")["id"]
23
-
24
- # now send a query about your permissions
25
- result = @rest.fql_query("select read_stream from permissions where uid = #{id}")
26
-
27
- result.size.should == 1
28
- # we assume that you have read_stream permissions, so we can test against that
29
- # (should we keep this?)
30
- result.first["read_stream"].should == 1
31
- end
32
- end
33
- end