koala 0.10.0 → 1.0.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.
- data/.gitignore +3 -0
- data/CHANGELOG +37 -7
- data/Gemfile +3 -0
- data/LICENSE +1 -1
- data/Manifest +8 -1
- data/Rakefile +13 -14
- data/koala.gemspec +36 -19
- data/lib/koala/graph_api.rb +188 -123
- data/lib/koala/http_services.rb +93 -18
- data/lib/koala/rest_api.rb +73 -6
- data/lib/koala/test_users.rb +21 -8
- data/lib/koala/uploadable_io.rb +115 -0
- data/lib/koala.rb +104 -120
- data/readme.md +29 -16
- data/spec/cases/api_base_spec.rb +101 -0
- data/spec/cases/graph_and_rest_api_spec.rb +31 -0
- data/spec/cases/graph_api_spec.rb +25 -0
- data/spec/cases/http_services/http_service_spec.rb +54 -0
- data/spec/cases/http_services/net_http_service_spec.rb +350 -0
- data/spec/cases/http_services/typhoeus_service_spec.rb +144 -0
- data/spec/cases/oauth_spec.rb +409 -0
- data/spec/cases/realtime_updates_spec.rb +184 -0
- data/spec/cases/rest_api_spec.rb +25 -0
- data/spec/{koala/test_users/test_users_tests.rb → cases/test_users_spec.rb} +78 -72
- data/spec/cases/uploadable_io_spec.rb +151 -0
- data/spec/fixtures/beach.jpg +0 -0
- data/spec/{facebook_data.yml → fixtures/facebook_data.yml} +13 -9
- data/spec/{mock_facebook_responses.yml → fixtures/mock_facebook_responses.yml} +314 -289
- data/spec/spec_helper.rb +18 -0
- data/spec/support/graph_api_shared_examples.rb +424 -0
- data/spec/{koala → support}/live_testing_data_helper.rb +39 -42
- data/spec/{mock_http_service.rb → support/mock_http_service.rb} +94 -81
- data/spec/support/rest_api_shared_examples.rb +161 -0
- data/spec/support/setup_mocks_or_live.rb +52 -0
- data/spec/support/uploadable_io_shared_examples.rb +76 -0
- metadata +127 -43
- data/init.rb +0 -2
- data/spec/koala/api_base_tests.rb +0 -102
- data/spec/koala/graph_and_rest_api/graph_and_rest_api_no_token_tests.rb +0 -10
- data/spec/koala/graph_and_rest_api/graph_and_rest_api_with_token_tests.rb +0 -11
- data/spec/koala/graph_api/graph_api_no_access_token_tests.rb +0 -114
- data/spec/koala/graph_api/graph_api_with_access_token_tests.rb +0 -150
- data/spec/koala/graph_api/graph_collection_tests.rb +0 -104
- data/spec/koala/net_http_service_tests.rb +0 -186
- data/spec/koala/oauth/oauth_tests.rb +0 -438
- data/spec/koala/realtime_updates/realtime_updates_tests.rb +0 -187
- data/spec/koala/rest_api/rest_api_no_access_token_tests.rb +0 -94
- data/spec/koala/rest_api/rest_api_with_access_token_tests.rb +0 -36
- data/spec/koala_spec.rb +0 -18
- data/spec/koala_spec_helper.rb +0 -48
- data/spec/koala_spec_without_mocks.rb +0 -19
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
include Koala
|
|
1
|
+
require 'spec_helper'
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
describe "Koala::Facebook::TestUsers" do
|
|
4
|
+
context "with access token" do
|
|
5
5
|
include LiveTestingDataHelper
|
|
6
6
|
|
|
7
7
|
before :all do
|
|
@@ -10,40 +10,40 @@ class TestUsersTests < Test::Unit::TestCase
|
|
|
10
10
|
@app_id = @oauth_data["app_id"]
|
|
11
11
|
@secret = @oauth_data["secret"]
|
|
12
12
|
@app_access_token = @oauth_data["app_access_token"]
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
# check OAuth data
|
|
15
15
|
unless @app_id && @secret && @app_access_token
|
|
16
|
-
raise Exception, "Must supply OAuth app id, secret, app_access_token, and callback to run live subscription tests!"
|
|
16
|
+
raise Exception, "Must supply OAuth app id, secret, app_access_token, and callback to run live subscription tests!"
|
|
17
17
|
end
|
|
18
|
-
|
|
18
|
+
|
|
19
19
|
@is_mock = defined?(Koala::IS_MOCK) && Koala::IS_MOCK
|
|
20
20
|
end
|
|
21
|
-
|
|
21
|
+
|
|
22
22
|
describe "when initializing" do
|
|
23
23
|
# basic initialization
|
|
24
24
|
it "should initialize properly with an app_id and an app_access_token" do
|
|
25
|
-
test_users = Facebook::TestUsers.new(:app_id => @app_id, :app_access_token => @app_access_token)
|
|
26
|
-
test_users.should be_a(Facebook::TestUsers)
|
|
25
|
+
test_users = Koala::Facebook::TestUsers.new(:app_id => @app_id, :app_access_token => @app_access_token)
|
|
26
|
+
test_users.should be_a(Koala::Facebook::TestUsers)
|
|
27
27
|
end
|
|
28
|
-
|
|
28
|
+
|
|
29
29
|
# init with secret / fetching the token
|
|
30
|
-
it "should initialize properly with an app_id and a secret" do
|
|
31
|
-
test_users = Facebook::TestUsers.new(:app_id => @app_id, :secret => @secret)
|
|
32
|
-
test_users.should be_a(Facebook::TestUsers)
|
|
30
|
+
it "should initialize properly with an app_id and a secret" do
|
|
31
|
+
test_users = Koala::Facebook::TestUsers.new(:app_id => @app_id, :secret => @secret)
|
|
32
|
+
test_users.should be_a(Koala::Facebook::TestUsers)
|
|
33
33
|
end
|
|
34
|
-
|
|
34
|
+
|
|
35
35
|
it "should use the OAuth class to fetch a token when provided an app_id and a secret" do
|
|
36
|
-
oauth = Facebook::OAuth.new(@app_id, @secret)
|
|
36
|
+
oauth = Koala::Facebook::OAuth.new(@app_id, @secret)
|
|
37
37
|
token = oauth.get_app_access_token
|
|
38
38
|
oauth.should_receive(:get_app_access_token).and_return(token)
|
|
39
|
-
Facebook::OAuth.should_receive(:new).with(@app_id, @secret).and_return(oauth)
|
|
40
|
-
test_users = Facebook::TestUsers.new(:app_id => @app_id, :secret => @secret)
|
|
39
|
+
Koala::Facebook::OAuth.should_receive(:new).with(@app_id, @secret).and_return(oauth)
|
|
40
|
+
test_users = Koala::Facebook::TestUsers.new(:app_id => @app_id, :secret => @secret)
|
|
41
41
|
end
|
|
42
42
|
end
|
|
43
|
-
|
|
43
|
+
|
|
44
44
|
describe "when used without network" do
|
|
45
45
|
before :each do
|
|
46
|
-
@test_users = Facebook::TestUsers.new({:app_access_token => @app_access_token, :app_id => @app_id})
|
|
46
|
+
@test_users = Koala::Facebook::TestUsers.new({:app_access_token => @app_access_token, :app_id => @app_id})
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
# TEST USER MANAGEMENT
|
|
@@ -53,31 +53,43 @@ class TestUsersTests < Test::Unit::TestCase
|
|
|
53
53
|
result.should be_a(Hash)
|
|
54
54
|
(result["id"] && result["access_token"] && result["login_url"]).should
|
|
55
55
|
end
|
|
56
|
-
|
|
56
|
+
|
|
57
57
|
it "should create a test user when not given installed, ignoring permissions" do
|
|
58
58
|
result = @test_users.create(false, "read_stream")
|
|
59
59
|
@temporary_object_id = result["id"]
|
|
60
60
|
result.should be_a(Hash)
|
|
61
61
|
(result["id"] && result["access_token"] && result["login_url"]).should
|
|
62
62
|
end
|
|
63
|
-
|
|
63
|
+
|
|
64
64
|
it "should accept permissions as a string" do
|
|
65
|
-
@test_users.graph_api.should_receive(:graph_call).with(anything, hash_including("permissions" => "read_stream,publish_stream"), anything)
|
|
65
|
+
@test_users.graph_api.should_receive(:graph_call).with(anything, hash_including("permissions" => "read_stream,publish_stream"), anything, anything)
|
|
66
66
|
result = @test_users.create(true, "read_stream,publish_stream")
|
|
67
67
|
end
|
|
68
|
-
|
|
68
|
+
|
|
69
69
|
it "should accept permissions as an array" do
|
|
70
|
-
@test_users.graph_api.should_receive(:graph_call).with(anything, hash_including("permissions" => "read_stream,publish_stream"), anything)
|
|
70
|
+
@test_users.graph_api.should_receive(:graph_call).with(anything, hash_including("permissions" => "read_stream,publish_stream"), anything, anything)
|
|
71
71
|
result = @test_users.create(true, ["read_stream", "publish_stream"])
|
|
72
72
|
end
|
|
73
|
-
|
|
73
|
+
|
|
74
74
|
it "should create a test user when given installed and a permission" do
|
|
75
75
|
result = @test_users.create(true, "read_stream")
|
|
76
76
|
@temporary_object_id = result["id"]
|
|
77
77
|
result.should be_a(Hash)
|
|
78
78
|
(result["id"] && result["access_token"] && result["login_url"]).should
|
|
79
79
|
end
|
|
80
|
-
|
|
80
|
+
|
|
81
|
+
it "lets you specify other graph arguments, like uid and access token" do
|
|
82
|
+
args = {:uid => "some test user ID", :owner_access_token => "some owner access token"}
|
|
83
|
+
@test_users.graph_api.should_receive(:graph_call).with(anything, hash_including(args), anything, anything)
|
|
84
|
+
@test_users.create(true, nil, args)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
it "lets you specify http options that get passed through to the graph call" do
|
|
88
|
+
options = {:some_http_option => true}
|
|
89
|
+
@test_users.graph_api.should_receive(:graph_call).with(anything, anything, anything, options)
|
|
90
|
+
@test_users.create(true, nil, {}, options)
|
|
91
|
+
end
|
|
92
|
+
|
|
81
93
|
describe "with a user to delete" do
|
|
82
94
|
before :each do
|
|
83
95
|
@user1 = @test_users.create(true, "read_stream")
|
|
@@ -85,27 +97,25 @@ class TestUsersTests < Test::Unit::TestCase
|
|
|
85
97
|
end
|
|
86
98
|
|
|
87
99
|
after :each do
|
|
88
|
-
print "\nCleaning up test users..."
|
|
89
100
|
@test_users.delete(@user1) if @user1
|
|
90
|
-
@test_users.delete(@user2) if @user2
|
|
91
|
-
puts "done."
|
|
101
|
+
@test_users.delete(@user2) if @user2
|
|
92
102
|
end
|
|
93
|
-
|
|
103
|
+
|
|
94
104
|
it "should delete a user by id" do
|
|
95
105
|
@test_users.delete(@user1['id']).should be_true
|
|
96
106
|
@user1 = nil
|
|
97
107
|
end
|
|
98
|
-
|
|
108
|
+
|
|
99
109
|
it "should delete a user by hash" do
|
|
100
110
|
@test_users.delete(@user2).should be_true
|
|
101
111
|
@user2 = nil
|
|
102
112
|
end
|
|
103
|
-
|
|
113
|
+
|
|
104
114
|
it "should not delete users when provided a false ID" do
|
|
105
115
|
lambda { @test_users.delete("#{@user1['id']}1") }.should raise_exception(Koala::Facebook::APIError)
|
|
106
116
|
end
|
|
107
117
|
end
|
|
108
|
-
|
|
118
|
+
|
|
109
119
|
describe "with delete_all" do
|
|
110
120
|
it "should delete all users found by the list commnand" do
|
|
111
121
|
array = [1, 2, 3]
|
|
@@ -114,18 +124,18 @@ class TestUsersTests < Test::Unit::TestCase
|
|
|
114
124
|
@test_users.delete_all
|
|
115
125
|
end
|
|
116
126
|
end
|
|
117
|
-
|
|
127
|
+
|
|
118
128
|
describe "with existing users" do
|
|
119
129
|
before :each do
|
|
120
130
|
@user1 = @test_users.create(true, "read_stream")
|
|
121
131
|
@user2 = @test_users.create(true, "read_stream,user_interests")
|
|
122
132
|
end
|
|
123
|
-
|
|
133
|
+
|
|
124
134
|
after :each do
|
|
125
135
|
@test_users.delete(@user1)
|
|
126
136
|
@test_users.delete(@user2)
|
|
127
137
|
end
|
|
128
|
-
|
|
138
|
+
|
|
129
139
|
it "should list test users" do
|
|
130
140
|
result = @test_users.list
|
|
131
141
|
result.should be_an(Array)
|
|
@@ -133,67 +143,64 @@ class TestUsersTests < Test::Unit::TestCase
|
|
|
133
143
|
(first_user["id"] && first_user["access_token"] && first_user["login_url"]).should
|
|
134
144
|
(second_user["id"] && second_user["access_token"] && second_user["login_url"]).should
|
|
135
145
|
end
|
|
136
|
-
|
|
137
|
-
it "should make two users into friends
|
|
138
|
-
result = @test_users.befriend(@user1
|
|
146
|
+
|
|
147
|
+
it "should make two users into friends with string hashes" do
|
|
148
|
+
result = @test_users.befriend(@user1, @user2)
|
|
139
149
|
result.should be_true
|
|
140
150
|
end
|
|
151
|
+
|
|
152
|
+
it "should make two users into friends with symbol hashes" do
|
|
153
|
+
new_user_1 = {}
|
|
154
|
+
@user1.each_pair {|k, v| new_user_1[k.to_sym] = v}
|
|
155
|
+
new_user_2 = {}
|
|
156
|
+
@user2.each_pair {|k, v| new_user_2[k.to_sym] = v}
|
|
141
157
|
|
|
142
|
-
|
|
143
|
-
result = @test_users.befriend(@user1, @user2)
|
|
158
|
+
result = @test_users.befriend(new_user_1, new_user_2)
|
|
144
159
|
result.should be_true
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
it "should not accept user IDs anymore" do
|
|
163
|
+
lambda { @test_users.befriend(@user1["id"], @user2["id"]) }.should raise_exception
|
|
145
164
|
end
|
|
146
|
-
|
|
147
165
|
end # with existing users
|
|
148
|
-
|
|
166
|
+
|
|
149
167
|
end # when used without network
|
|
150
|
-
|
|
151
|
-
describe "when creating a network of friends" do
|
|
168
|
+
|
|
169
|
+
describe "when creating a network of friends" do
|
|
152
170
|
before :each do
|
|
153
|
-
@test_users = Facebook::TestUsers.new({:app_access_token => @app_access_token, :app_id => @app_id})
|
|
171
|
+
@test_users = Koala::Facebook::TestUsers.new({:app_access_token => @app_access_token, :app_id => @app_id})
|
|
154
172
|
@network = []
|
|
155
|
-
|
|
173
|
+
|
|
156
174
|
if @is_mock
|
|
157
175
|
id_counter = 999999900
|
|
158
176
|
@test_users.stub!(:create).and_return do
|
|
159
177
|
id_counter += 1
|
|
160
|
-
{"id" => id_counter, "access_token" =>
|
|
178
|
+
{"id" => id_counter, "access_token" => @token, "login_url" => "https://www.facebook.com/platform/test_account.."}
|
|
161
179
|
end
|
|
162
180
|
@test_users.stub!(:befriend).and_return(true)
|
|
163
181
|
@test_users.stub!(:delete).and_return(true)
|
|
164
182
|
end
|
|
165
183
|
end
|
|
166
|
-
|
|
184
|
+
|
|
167
185
|
describe "tests that create users" do
|
|
168
186
|
before :each do
|
|
169
|
-
|
|
170
|
-
test_users = Facebook::TestUsers.new({:app_access_token => @app_access_token, :app_id => @app_id})
|
|
187
|
+
test_users = Koala::Facebook::TestUsers.new({:app_access_token => @app_access_token, :app_id => @app_id})
|
|
171
188
|
test_users.delete_all
|
|
172
|
-
puts "done!"
|
|
173
189
|
end
|
|
174
190
|
|
|
175
191
|
after :each do
|
|
176
|
-
|
|
177
|
-
test_users = Facebook::TestUsers.new({:app_access_token => @app_access_token, :app_id => @app_id})
|
|
192
|
+
test_users = Koala::Facebook::TestUsers.new({:app_access_token => @app_access_token, :app_id => @app_id})
|
|
178
193
|
test_users.delete_all
|
|
179
|
-
puts "done!"
|
|
180
|
-
end
|
|
181
|
-
|
|
182
|
-
it "should create a 2 person network" do
|
|
183
|
-
@network = @test_users.create_network(2)
|
|
184
|
-
@network.should be_a(Array)
|
|
185
|
-
@network.size.should == 2
|
|
186
194
|
end
|
|
187
|
-
|
|
188
|
-
it "should create a
|
|
189
|
-
|
|
190
|
-
@network = @test_users.create_network(
|
|
195
|
+
|
|
196
|
+
it "should create a 5 person network" do
|
|
197
|
+
size = 5
|
|
198
|
+
@network = @test_users.create_network(size)
|
|
191
199
|
@network.should be_a(Array)
|
|
192
|
-
@network.size.should ==
|
|
193
|
-
puts "done!"
|
|
200
|
+
@network.size.should == size
|
|
194
201
|
end
|
|
195
202
|
end
|
|
196
|
-
|
|
203
|
+
|
|
197
204
|
it "should limit to a 50 person network" do
|
|
198
205
|
@test_users.should_receive(:create).exactly(50).times
|
|
199
206
|
@test_users.stub!(:befriend)
|
|
@@ -208,8 +215,7 @@ class TestUsersTests < Test::Unit::TestCase
|
|
|
208
215
|
@test_users.stub!(:befriend)
|
|
209
216
|
@network = @test_users.create_network(count, installed, perms)
|
|
210
217
|
end
|
|
211
|
-
|
|
212
|
-
end # when creating network
|
|
213
218
|
|
|
214
|
-
|
|
215
|
-
end
|
|
219
|
+
end # when creating network
|
|
220
|
+
end
|
|
221
|
+
end # describe Koala TestUsers
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# fake MIME::Types
|
|
2
|
+
module Koala::MIME
|
|
3
|
+
module Types
|
|
4
|
+
def self.type_for(type)
|
|
5
|
+
# this should be faked out in tests
|
|
6
|
+
nil
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
describe "Koala::UploadableIO" do
|
|
12
|
+
describe "the constructor" do
|
|
13
|
+
describe "when given a file path" do
|
|
14
|
+
before(:each) do
|
|
15
|
+
@koala_io_params = [File.open(BEACH_BALL_PATH)]
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
describe "and a content type" do
|
|
19
|
+
before :each do
|
|
20
|
+
@koala_io_params.concat([stub("image/jpg")])
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "should return an UploadIO with the same file path" do
|
|
24
|
+
stub_path = @koala_io_params[0] = "/stub/path/to/file"
|
|
25
|
+
Koala::UploadableIO.new(*@koala_io_params).io_or_path.should == stub_path
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "should return an UploadIO with the same content type" do
|
|
29
|
+
stub_type = @koala_io_params[1] = stub('Content Type')
|
|
30
|
+
Koala::UploadableIO.new(*@koala_io_params).content_type.should == stub_type
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
describe "and no content type" do
|
|
35
|
+
it_should_behave_like "determining a mime type"
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
describe "when given a File object" do
|
|
40
|
+
before(:each) do
|
|
41
|
+
@koala_io_params = [File.open(BEACH_BALL_PATH)]
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
describe "and a content type" do
|
|
45
|
+
before :each do
|
|
46
|
+
@koala_io_params.concat(["image/jpg"])
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it "should return an UploadIO with the same io" do
|
|
50
|
+
Koala::UploadableIO.new(*@koala_io_params).io_or_path.should == @koala_io_params[0]
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it "should return an UplaodIO with the same content_type" do
|
|
54
|
+
content_stub = @koala_io_params[1] = stub('Content Type')
|
|
55
|
+
Koala::UploadableIO.new(*@koala_io_params).content_type.should == content_stub
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
describe "and no content type" do
|
|
60
|
+
it_should_behave_like "determining a mime type"
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
describe "when given a Rails 3 ActionDispatch::Http::UploadedFile" do
|
|
65
|
+
before(:each) do
|
|
66
|
+
@tempfile = stub('Tempfile', :path => "foo")
|
|
67
|
+
@uploaded_file = stub('ActionDispatch::Http::UploadedFile',
|
|
68
|
+
:content_type => true,
|
|
69
|
+
:tempfile => @tempfile
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
@tempfile.stub!(:respond_to?).with(:path).and_return(true)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
it "should get the content type via the content_type method" do
|
|
76
|
+
expected_content_type = stub('Content Type')
|
|
77
|
+
@uploaded_file.should_receive(:content_type).and_return(expected_content_type)
|
|
78
|
+
Koala::UploadableIO.new(@uploaded_file).content_type.should == expected_content_type
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it "should get the path from the tempfile associated with the UploadedFile" do
|
|
82
|
+
expected_path = stub('Tempfile')
|
|
83
|
+
@tempfile.should_receive(:path).and_return(expected_path)
|
|
84
|
+
Koala::UploadableIO.new(@uploaded_file).io_or_path.should == expected_path
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
describe "when given a Sinatra file parameter hash" do
|
|
89
|
+
before(:each) do
|
|
90
|
+
@file_hash = {
|
|
91
|
+
:type => "type",
|
|
92
|
+
:tempfile => "Tempfile"
|
|
93
|
+
}
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
it "should get the content type from the :type key" do
|
|
97
|
+
expected_content_type = stub('Content Type')
|
|
98
|
+
@file_hash[:type] = expected_content_type
|
|
99
|
+
|
|
100
|
+
uploadable = Koala::UploadableIO.new(@file_hash)
|
|
101
|
+
uploadable.content_type.should == expected_content_type
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
it "should get the io_or_path from the :tempfile key" do
|
|
105
|
+
expected_file = stub('File')
|
|
106
|
+
@file_hash[:tempfile] = expected_file
|
|
107
|
+
|
|
108
|
+
uploadable = Koala::UploadableIO.new(@file_hash)
|
|
109
|
+
uploadable.io_or_path.should == expected_file
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
describe "for files with with recognizable MIME types" do
|
|
114
|
+
# what that means is tested below
|
|
115
|
+
it "should accept a file object alone" do
|
|
116
|
+
params = [BEACH_BALL_PATH]
|
|
117
|
+
lambda { Koala::UploadableIO.new(*params) }.should_not raise_exception(Koala::KoalaError)
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
it "should accept a file path alone" do
|
|
121
|
+
params = [BEACH_BALL_PATH]
|
|
122
|
+
lambda { Koala::UploadableIO.new(*params) }.should_not raise_exception(Koala::KoalaError)
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
describe "getting an UploadableIO" do
|
|
128
|
+
before(:each) do
|
|
129
|
+
@upload_io = stub("UploadIO")
|
|
130
|
+
UploadIO.stub!(:new).with(anything, anything, anything).and_return(@upload_io)
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
it "should call the constructor with the content type, file name, and a dummy file name" do
|
|
134
|
+
UploadIO.should_receive(:new).with(BEACH_BALL_PATH, "content/type", anything).and_return(@upload_io)
|
|
135
|
+
Koala::UploadableIO.new(BEACH_BALL_PATH, "content/type").to_upload_io.should == @upload_io
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
describe "getting a file" do
|
|
140
|
+
it "should return the File if initialized with a file" do
|
|
141
|
+
f = File.new(BEACH_BALL_PATH)
|
|
142
|
+
Koala::UploadableIO.new(f).to_file.should == f
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
it "should open up and return a file corresponding to the path if io_or_path is a path" do
|
|
146
|
+
result = stub("File")
|
|
147
|
+
File.should_receive(:open).with(BEACH_BALL_PATH).and_return(result)
|
|
148
|
+
Koala::UploadableIO.new(BEACH_BALL_PATH).to_file.should == result
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
end # describe UploadableIO
|
|
Binary file
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
# Just remember to update all fields!
|
|
5
5
|
|
|
6
6
|
# You must supply this value yourself to test the GraphAPI class.
|
|
7
|
-
# Your OAuth token should have publish_stream and
|
|
7
|
+
# Your OAuth token should have publish_stream, read_stream, and user_photos permissions.
|
|
8
8
|
oauth_token:
|
|
9
9
|
|
|
10
10
|
# for testing the OAuth class
|
|
@@ -35,17 +35,21 @@ oauth_test_data:
|
|
|
35
35
|
# note: I've revoked the offline access for security reasons, so you can't make calls against this :)
|
|
36
36
|
fbs_119908831367602: '"access_token=119908831367602|08170230801eb225068e7a70-2905623|Q3LDCYYF8CX9cstxnZLsxiR0nwg.&expires=0&secret=78abaee300b392e275072a9f2727d436&session_key=08170230801eb225068e7a70-2905623&sig=423b8aa4b6fa1f9a571955f8e929d567&uid=2905623"'
|
|
37
37
|
|
|
38
|
-
# These values will work out of the box
|
|
39
|
-
# They're from Facebook's example at http://developers.facebook.com/docs/authentication/canvas
|
|
38
|
+
# These values from the OAuth Playground (see above) will work out of the box
|
|
40
39
|
# You can update this to live data if desired
|
|
41
40
|
# request_secret is optional and will fall back to the secret above if absent
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
"0": payload
|
|
41
|
+
signed_params: "zWRm0gd5oHW_jzXP_WA9CirO7c5CLHotn-SKRqH2NmU.eyJhbGdvcml0aG0iOiJITUFDLVNIQTI1NiIsImV4cGlyZXMiOjEzMDE5MjIwMDAsImlzc3VlZF9hdCI6MTMwMTkxNzI5OSwib2F1dGhfdG9rZW4iOiIxMTk5MDg4MzEzNjc2MDJ8Mi56VkZfNk5yTUVMSHVKYTRnSVU5dEt3X18uMzYwMC4xMzAxOTIyMDAwLTI5MDU2MjN8emdxUHNyMkJHOUxvT0s5a2VrR2dSVVJaeDBrIiwidXNlciI6eyJjb3VudHJ5IjoiZGUiLCJsb2NhbGUiOiJkZV9ERSIsImFnZSI6eyJtaW4iOjIxfX0sInVzZXJfaWQiOiIyOTA1NjIzIn0"
|
|
42
|
+
signed_params_result:
|
|
43
|
+
expires: 1301922000
|
|
46
44
|
algorithm: HMAC-SHA256
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
user_id: "2905623"
|
|
46
|
+
oauth_token: 119908831367602|2.zVF_6NrMELHuJa4gIU9tKw__.3600.1301922000-2905623|zgqPsr2BG9LoOK9kekGgRURZx0k
|
|
47
|
+
user:
|
|
48
|
+
country: de
|
|
49
|
+
locale: de_DE
|
|
50
|
+
age:
|
|
51
|
+
min: 21
|
|
52
|
+
issued_at: 1301917299
|
|
49
53
|
|
|
50
54
|
subscription_test_data:
|
|
51
55
|
subscription_path: http://oauth.twoalex.com/subscriptions
|