koala 1.0.0 → 1.2.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/.autotest +12 -0
- data/.gitignore +3 -1
- data/.travis.yml +9 -0
- data/CHANGELOG +62 -2
- data/Gemfile +8 -0
- data/Rakefile +0 -1
- data/autotest/discover.rb +1 -0
- data/koala.gemspec +13 -14
- data/lib/koala/batch_operation.rb +74 -0
- data/lib/koala/graph_api.rb +145 -132
- data/lib/koala/graph_batch_api.rb +97 -0
- data/lib/koala/graph_collection.rb +59 -0
- data/lib/koala/http_service.rb +176 -0
- data/lib/koala/oauth.rb +191 -0
- data/lib/koala/realtime_updates.rb +23 -29
- data/lib/koala/rest_api.rb +13 -8
- data/lib/koala/test_users.rb +33 -17
- data/lib/koala/uploadable_io.rb +153 -87
- data/lib/koala/utils.rb +11 -0
- data/lib/koala/version.rb +3 -0
- data/lib/koala.rb +59 -217
- data/readme.md +92 -53
- data/spec/cases/{api_base_spec.rb → api_spec.rb} +31 -6
- data/spec/cases/error_spec.rb +32 -0
- data/spec/cases/graph_and_rest_api_spec.rb +12 -21
- data/spec/cases/graph_api_batch_spec.rb +582 -0
- data/spec/cases/graph_api_spec.rb +11 -14
- data/spec/cases/graph_collection_spec.rb +116 -0
- data/spec/cases/http_service_spec.rb +446 -0
- data/spec/cases/koala_spec.rb +54 -0
- data/spec/cases/oauth_spec.rb +319 -213
- data/spec/cases/realtime_updates_spec.rb +45 -31
- data/spec/cases/rest_api_spec.rb +23 -7
- data/spec/cases/test_users_spec.rb +123 -75
- data/spec/cases/uploadable_io_spec.rb +120 -37
- data/spec/cases/utils_spec.rb +10 -0
- data/spec/fixtures/cat.m4v +0 -0
- data/spec/fixtures/facebook_data.yml +26 -24
- data/spec/fixtures/mock_facebook_responses.yml +203 -78
- data/spec/spec_helper.rb +30 -5
- data/spec/support/graph_api_shared_examples.rb +149 -118
- data/spec/support/json_testing_fix.rb +42 -0
- data/spec/support/koala_test.rb +187 -0
- data/spec/support/mock_http_service.rb +62 -58
- data/spec/support/ordered_hash.rb +205 -0
- data/spec/support/rest_api_shared_examples.rb +139 -15
- data/spec/support/uploadable_io_shared_examples.rb +2 -8
- metadata +90 -114
- data/lib/koala/http_services.rb +0 -146
- data/spec/cases/http_services/http_service_spec.rb +0 -54
- data/spec/cases/http_services/net_http_service_spec.rb +0 -350
- data/spec/cases/http_services/typhoeus_service_spec.rb +0 -144
- data/spec/support/live_testing_data_helper.rb +0 -40
- data/spec/support/setup_mocks_or_live.rb +0 -52
|
@@ -3,11 +3,10 @@ require 'spec_helper'
|
|
|
3
3
|
describe "Koala::Facebook::RealtimeUpdates" do
|
|
4
4
|
before :all do
|
|
5
5
|
# get oauth data
|
|
6
|
-
@
|
|
7
|
-
@
|
|
8
|
-
@
|
|
9
|
-
@
|
|
10
|
-
@app_access_token = @oauth_data["app_access_token"]
|
|
6
|
+
@app_id = KoalaTest.app_id
|
|
7
|
+
@secret = KoalaTest.secret
|
|
8
|
+
@callback_url = KoalaTest.oauth_test_data["callback_url"]
|
|
9
|
+
@app_access_token = KoalaTest.app_access_token
|
|
11
10
|
|
|
12
11
|
# check OAuth data
|
|
13
12
|
unless @app_id && @secret && @callback_url && @app_access_token
|
|
@@ -15,14 +14,13 @@ describe "Koala::Facebook::RealtimeUpdates" do
|
|
|
15
14
|
end
|
|
16
15
|
|
|
17
16
|
# get subscription data
|
|
18
|
-
@
|
|
19
|
-
@
|
|
20
|
-
@
|
|
21
|
-
@subscription_path = @subscription_data["subscription_path"]
|
|
17
|
+
@verify_token = KoalaTest.subscription_test_data["verify_token"]
|
|
18
|
+
@challenge_data = KoalaTest.subscription_test_data["challenge_data"]
|
|
19
|
+
@subscription_path = KoalaTest.subscription_test_data["subscription_path"]
|
|
22
20
|
|
|
23
21
|
# check subscription data
|
|
24
22
|
unless @verify_token && @challenge_data && @subscription_path
|
|
25
|
-
raise Exception, "Must supply verify_token and equivalent challenge_data to run
|
|
23
|
+
raise Exception, "Must supply verify_token and equivalent challenge_data to run subscription tests!"
|
|
26
24
|
end
|
|
27
25
|
end
|
|
28
26
|
|
|
@@ -34,28 +32,40 @@ describe "Koala::Facebook::RealtimeUpdates" do
|
|
|
34
32
|
end
|
|
35
33
|
|
|
36
34
|
# attributes
|
|
37
|
-
it "should allow read access to app_id
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
it "should allow read access to app_id" do
|
|
36
|
+
# in Ruby 1.9, .method returns symbols
|
|
37
|
+
Koala::Facebook::RealtimeUpdates.instance_methods.map(&:to_sym).should include(:app_id)
|
|
38
|
+
Koala::Facebook::RealtimeUpdates.instance_methods.map(&:to_sym).should_not include(:app_id=)
|
|
41
39
|
end
|
|
42
|
-
|
|
43
|
-
it "should
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
40
|
+
|
|
41
|
+
it "should allow read access to app_access_token" do
|
|
42
|
+
# in Ruby 1.9, .method returns symbols
|
|
43
|
+
Koala::Facebook::RealtimeUpdates.instance_methods.map(&:to_sym).should include(:app_access_token)
|
|
44
|
+
Koala::Facebook::RealtimeUpdates.instance_methods.map(&:to_sym).should_not include(:app_access_token=)
|
|
47
45
|
end
|
|
48
46
|
|
|
49
|
-
it "should
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
it "should allow read access to secret" do
|
|
48
|
+
# in Ruby 1.9, .method returns symbols
|
|
49
|
+
Koala::Facebook::RealtimeUpdates.instance_methods.map(&:to_sym).should include(:secret)
|
|
50
|
+
Koala::Facebook::RealtimeUpdates.instance_methods.map(&:to_sym).should_not include(:secret=)
|
|
53
51
|
end
|
|
54
|
-
|
|
55
|
-
it "should
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
52
|
+
|
|
53
|
+
it "should allow read access to api" do
|
|
54
|
+
# in Ruby 1.9, .method returns symbols
|
|
55
|
+
Koala::Facebook::RealtimeUpdates.instance_methods.map(&:to_sym).should include(:api)
|
|
56
|
+
Koala::Facebook::RealtimeUpdates.instance_methods.map(&:to_sym).should_not include(:api=)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# old graph_api accessor
|
|
60
|
+
it "returns the api object when graph_api is called" do
|
|
61
|
+
updates = Koala::Facebook::RealtimeUpdates.new(:app_id => @app_id, :secret => @secret)
|
|
62
|
+
updates.graph_api.should == updates.api
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it "fire a deprecation warning when graph_api is called" do
|
|
66
|
+
updates = Koala::Facebook::RealtimeUpdates.new(:app_id => @app_id, :secret => @secret)
|
|
67
|
+
Koala::Utils.should_receive(:deprecate)
|
|
68
|
+
updates.graph_api
|
|
59
69
|
end
|
|
60
70
|
|
|
61
71
|
# init with secret / fetching the token
|
|
@@ -151,20 +161,24 @@ describe "Koala::Facebook::RealtimeUpdates" do
|
|
|
151
161
|
end
|
|
152
162
|
|
|
153
163
|
describe "and a block is given" do
|
|
164
|
+
before :each do
|
|
165
|
+
@params['hub.verify_token'] = @token
|
|
166
|
+
end
|
|
167
|
+
|
|
154
168
|
it "should give the block the token as a parameter" do
|
|
155
|
-
Koala::Facebook::RealtimeUpdates.meet_challenge(@params)do |token|
|
|
169
|
+
Koala::Facebook::RealtimeUpdates.meet_challenge(@params) do |token|
|
|
156
170
|
token.should == @token
|
|
157
171
|
end
|
|
158
172
|
end
|
|
159
173
|
|
|
160
174
|
it "should return false if the given block return false" do
|
|
161
|
-
Koala::Facebook::RealtimeUpdates.meet_challenge(@params)do |token|
|
|
175
|
+
Koala::Facebook::RealtimeUpdates.meet_challenge(@params) do |token|
|
|
162
176
|
false
|
|
163
177
|
end.should be_false
|
|
164
178
|
end
|
|
165
179
|
|
|
166
180
|
it "should return false if the given block returns nil" do
|
|
167
|
-
Koala::Facebook::RealtimeUpdates.meet_challenge(@params)do |token|
|
|
181
|
+
Koala::Facebook::RealtimeUpdates.meet_challenge(@params) do |token|
|
|
168
182
|
nil
|
|
169
183
|
end.should be_false
|
|
170
184
|
end
|
data/spec/cases/rest_api_spec.rb
CHANGED
|
@@ -1,25 +1,41 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe "Koala::Facebook::RestAPI" do
|
|
4
|
-
|
|
4
|
+
describe "class consolidation" do
|
|
5
|
+
before :each do
|
|
6
|
+
Koala::Utils.stub(:deprecate) # avoid actual messages to stderr
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
it "still allows you to instantiate a GraphAndRestAPI object" do
|
|
10
|
+
api = Koala::Facebook::RestAPI.new("token").should be_a(Koala::Facebook::RestAPI)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "ultimately creates an API object" do
|
|
14
|
+
api = Koala::Facebook::RestAPI.new("token").should be_a(Koala::Facebook::API)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "fires a depreciation warning" do
|
|
18
|
+
Koala::Utils.should_receive(:deprecate)
|
|
19
|
+
api = Koala::Facebook::RestAPI.new("token")
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
5
23
|
context "without an access token" do
|
|
6
24
|
before :each do
|
|
7
|
-
@api = Koala::Facebook::
|
|
25
|
+
@api = Koala::Facebook::API.new
|
|
8
26
|
end
|
|
9
27
|
|
|
10
28
|
it_should_behave_like "Koala RestAPI"
|
|
11
29
|
it_should_behave_like "Koala RestAPI without an access token"
|
|
12
30
|
end
|
|
13
|
-
|
|
14
|
-
context "with an access token" do
|
|
15
|
-
include LiveTestingDataHelper
|
|
16
31
|
|
|
32
|
+
context "with an access token" do
|
|
17
33
|
before :each do
|
|
18
|
-
@api = Koala::Facebook::
|
|
34
|
+
@api = Koala::Facebook::API.new(@token)
|
|
19
35
|
end
|
|
20
36
|
|
|
21
37
|
it_should_behave_like "Koala RestAPI"
|
|
22
38
|
it_should_behave_like "Koala RestAPI with an access token"
|
|
23
39
|
end
|
|
24
|
-
|
|
40
|
+
|
|
25
41
|
end
|
|
@@ -2,21 +2,23 @@ require 'spec_helper'
|
|
|
2
2
|
|
|
3
3
|
describe "Koala::Facebook::TestUsers" do
|
|
4
4
|
context "with access token" do
|
|
5
|
-
include LiveTestingDataHelper
|
|
6
|
-
|
|
7
5
|
before :all do
|
|
8
6
|
# get oauth data
|
|
9
|
-
@
|
|
10
|
-
@
|
|
11
|
-
@
|
|
12
|
-
@app_access_token = @oauth_data["app_access_token"]
|
|
7
|
+
@app_id = KoalaTest.app_id
|
|
8
|
+
@secret = KoalaTest.secret
|
|
9
|
+
@app_access_token = KoalaTest.app_access_token
|
|
13
10
|
|
|
14
11
|
# check OAuth data
|
|
15
12
|
unless @app_id && @secret && @app_access_token
|
|
16
13
|
raise Exception, "Must supply OAuth app id, secret, app_access_token, and callback to run live subscription tests!"
|
|
17
14
|
end
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
after :each do
|
|
18
|
+
# clean up any test users
|
|
19
|
+
((@network || []) + [@user1, @user2]).each do |u|
|
|
20
|
+
puts "Unable to delete test user #{u.inspect}" if u && (!@test_users.delete(u) rescue false)
|
|
21
|
+
end
|
|
20
22
|
end
|
|
21
23
|
|
|
22
24
|
describe "when initializing" do
|
|
@@ -39,68 +41,103 @@ describe "Koala::Facebook::TestUsers" do
|
|
|
39
41
|
Koala::Facebook::OAuth.should_receive(:new).with(@app_id, @secret).and_return(oauth)
|
|
40
42
|
test_users = Koala::Facebook::TestUsers.new(:app_id => @app_id, :secret => @secret)
|
|
41
43
|
end
|
|
42
|
-
end
|
|
43
44
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
# attributes
|
|
46
|
+
it "should allow read access to app_id, app_access_token, and secret" do
|
|
47
|
+
# in Ruby 1.9, .method returns symbols
|
|
48
|
+
Koala::Facebook::TestUsers.instance_methods.map(&:to_sym).should include(:app_id)
|
|
49
|
+
Koala::Facebook::TestUsers.instance_methods.map(&:to_sym).should_not include(:app_id=)
|
|
47
50
|
end
|
|
48
51
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
result.should be_a(Hash)
|
|
54
|
-
(result["id"] && result["access_token"] && result["login_url"]).should
|
|
52
|
+
it "should allow read access to app_access_token" do
|
|
53
|
+
# in Ruby 1.9, .method returns symbols
|
|
54
|
+
Koala::Facebook::TestUsers.instance_methods.map(&:to_sym).should include(:app_access_token)
|
|
55
|
+
Koala::Facebook::TestUsers.instance_methods.map(&:to_sym).should_not include(:app_access_token=)
|
|
55
56
|
end
|
|
56
57
|
|
|
57
|
-
it "should
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
(result["id"] && result["access_token"] && result["login_url"]).should
|
|
58
|
+
it "should allow read access to secret" do
|
|
59
|
+
# in Ruby 1.9, .method returns symbols
|
|
60
|
+
Koala::Facebook::TestUsers.instance_methods.map(&:to_sym).should include(:secret)
|
|
61
|
+
Koala::Facebook::TestUsers.instance_methods.map(&:to_sym).should_not include(:secret=)
|
|
62
62
|
end
|
|
63
63
|
|
|
64
|
-
it "should
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
it "should allow read access to api" do
|
|
65
|
+
# in Ruby 1.9, .method returns symbols
|
|
66
|
+
Koala::Facebook::TestUsers.instance_methods.map(&:to_sym).should include(:api)
|
|
67
|
+
Koala::Facebook::TestUsers.instance_methods.map(&:to_sym).should_not include(:api=)
|
|
67
68
|
end
|
|
68
69
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
# old graph_api accessor
|
|
71
|
+
it "returns the api object when graph_api is called" do
|
|
72
|
+
test_users = Koala::Facebook::TestUsers.new(:app_id => @app_id, :secret => @secret)
|
|
73
|
+
test_users.graph_api.should == test_users.api
|
|
72
74
|
end
|
|
73
75
|
|
|
74
|
-
it "
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
(result["id"] && result["access_token"] && result["login_url"]).should
|
|
76
|
+
it "fire a deprecation warning when graph_api is called" do
|
|
77
|
+
test_users = Koala::Facebook::TestUsers.new(:app_id => @app_id, :secret => @secret)
|
|
78
|
+
Koala::Utils.should_receive(:deprecate)
|
|
79
|
+
test_users.graph_api
|
|
79
80
|
end
|
|
81
|
+
end
|
|
80
82
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
@test_users.
|
|
84
|
-
@test_users.create(true, nil, args)
|
|
83
|
+
describe "when used without network" do
|
|
84
|
+
before :each do
|
|
85
|
+
@test_users = Koala::Facebook::TestUsers.new({:app_access_token => @app_access_token, :app_id => @app_id})
|
|
85
86
|
end
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
87
|
+
|
|
88
|
+
# TEST USER MANAGEMENT
|
|
89
|
+
|
|
90
|
+
describe ".create" do
|
|
91
|
+
it "should create a test user when not given installed" do
|
|
92
|
+
result = @test_users.create(false)
|
|
93
|
+
@temporary_object_id = result["id"]
|
|
94
|
+
result.should be_a(Hash)
|
|
95
|
+
(result["id"] && result["access_token"] && result["login_url"]).should
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
it "should create a test user when not given installed, ignoring permissions" do
|
|
99
|
+
result = @test_users.create(false, "read_stream")
|
|
100
|
+
@temporary_object_id = result["id"]
|
|
101
|
+
result.should be_a(Hash)
|
|
102
|
+
(result["id"] && result["access_token"] && result["login_url"]).should
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
it "should accept permissions as a string" do
|
|
106
|
+
@test_users.graph_api.should_receive(:graph_call).with(anything, hash_including("permissions" => "read_stream,publish_stream"), anything, anything)
|
|
107
|
+
result = @test_users.create(true, "read_stream,publish_stream")
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
it "should accept permissions as an array" do
|
|
111
|
+
@test_users.graph_api.should_receive(:graph_call).with(anything, hash_including("permissions" => "read_stream,publish_stream"), anything, anything)
|
|
112
|
+
result = @test_users.create(true, ["read_stream", "publish_stream"])
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
it "should create a test user when given installed and a permission" do
|
|
116
|
+
result = @test_users.create(true, "read_stream")
|
|
117
|
+
@temporary_object_id = result["id"]
|
|
118
|
+
result.should be_a(Hash)
|
|
119
|
+
(result["id"] && result["access_token"] && result["login_url"]).should
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
it "lets you specify other graph arguments, like uid and access token" do
|
|
123
|
+
args = {:uid => "some test user ID", :owner_access_token => "some owner access token"}
|
|
124
|
+
@test_users.graph_api.should_receive(:graph_call).with(anything, hash_including(args), anything, anything)
|
|
125
|
+
@test_users.create(true, nil, args)
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
it "lets you specify http options that get passed through to the graph call" do
|
|
129
|
+
options = {:some_http_option => true}
|
|
130
|
+
@test_users.graph_api.should_receive(:graph_call).with(anything, anything, anything, options)
|
|
131
|
+
@test_users.create(true, nil, {}, options)
|
|
132
|
+
end
|
|
91
133
|
end
|
|
92
134
|
|
|
93
|
-
describe "
|
|
135
|
+
describe ".delete" do
|
|
94
136
|
before :each do
|
|
95
137
|
@user1 = @test_users.create(true, "read_stream")
|
|
96
138
|
@user2 = @test_users.create(true, "read_stream,user_interests")
|
|
97
139
|
end
|
|
98
140
|
|
|
99
|
-
after :each do
|
|
100
|
-
@test_users.delete(@user1) if @user1
|
|
101
|
-
@test_users.delete(@user2) if @user2
|
|
102
|
-
end
|
|
103
|
-
|
|
104
141
|
it "should delete a user by id" do
|
|
105
142
|
@test_users.delete(@user1['id']).should be_true
|
|
106
143
|
@user1 = nil
|
|
@@ -116,7 +153,7 @@ describe "Koala::Facebook::TestUsers" do
|
|
|
116
153
|
end
|
|
117
154
|
end
|
|
118
155
|
|
|
119
|
-
describe "
|
|
156
|
+
describe ".delete_all" do
|
|
120
157
|
it "should delete all users found by the list commnand" do
|
|
121
158
|
array = [1, 2, 3]
|
|
122
159
|
@test_users.should_receive(:list).and_return(array)
|
|
@@ -125,17 +162,37 @@ describe "Koala::Facebook::TestUsers" do
|
|
|
125
162
|
end
|
|
126
163
|
end
|
|
127
164
|
|
|
165
|
+
describe ".update" do
|
|
166
|
+
before :each do
|
|
167
|
+
@updates = {:name => "Foo Baz"}
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
it "makes a POST with the test user Graph API " do
|
|
171
|
+
user = @test_users.create(true)
|
|
172
|
+
@test_users.graph_api.should_receive(:graph_call).with(anything, anything, "post", anything)
|
|
173
|
+
@test_users.update(user, @updates)
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
it "makes a request to the test user with the update params " do
|
|
177
|
+
user = @test_users.create(true)
|
|
178
|
+
@test_users.graph_api.should_receive(:graph_call).with(user["id"], @updates, anything, anything)
|
|
179
|
+
@test_users.update(user, @updates)
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
it "works" do
|
|
183
|
+
user = @test_users.create(true)
|
|
184
|
+
@test_users.update(user, @updates)
|
|
185
|
+
user_info = Koala::Facebook::API.new(user["access_token"]).get_object(user["id"])
|
|
186
|
+
user_info["name"].should == @updates[:name]
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
|
|
128
190
|
describe "with existing users" do
|
|
129
191
|
before :each do
|
|
130
192
|
@user1 = @test_users.create(true, "read_stream")
|
|
131
193
|
@user2 = @test_users.create(true, "read_stream,user_interests")
|
|
132
194
|
end
|
|
133
195
|
|
|
134
|
-
after :each do
|
|
135
|
-
@test_users.delete(@user1)
|
|
136
|
-
@test_users.delete(@user2)
|
|
137
|
-
end
|
|
138
|
-
|
|
139
196
|
it "should list test users" do
|
|
140
197
|
result = @test_users.list
|
|
141
198
|
result.should be_an(Array)
|
|
@@ -143,22 +200,22 @@ describe "Koala::Facebook::TestUsers" do
|
|
|
143
200
|
(first_user["id"] && first_user["access_token"] && first_user["login_url"]).should
|
|
144
201
|
(second_user["id"] && second_user["access_token"] && second_user["login_url"]).should
|
|
145
202
|
end
|
|
146
|
-
|
|
203
|
+
|
|
147
204
|
it "should make two users into friends with string hashes" do
|
|
148
205
|
result = @test_users.befriend(@user1, @user2)
|
|
149
206
|
result.should be_true
|
|
150
207
|
end
|
|
151
|
-
|
|
208
|
+
|
|
152
209
|
it "should make two users into friends with symbol hashes" do
|
|
153
210
|
new_user_1 = {}
|
|
154
211
|
@user1.each_pair {|k, v| new_user_1[k.to_sym] = v}
|
|
155
212
|
new_user_2 = {}
|
|
156
213
|
@user2.each_pair {|k, v| new_user_2[k.to_sym] = v}
|
|
157
|
-
|
|
214
|
+
|
|
158
215
|
result = @test_users.befriend(new_user_1, new_user_2)
|
|
159
216
|
result.should be_true
|
|
160
|
-
end
|
|
161
|
-
|
|
217
|
+
end
|
|
218
|
+
|
|
162
219
|
it "should not accept user IDs anymore" do
|
|
163
220
|
lambda { @test_users.befriend(@user1["id"], @user2["id"]) }.should raise_exception
|
|
164
221
|
end
|
|
@@ -171,7 +228,7 @@ describe "Koala::Facebook::TestUsers" do
|
|
|
171
228
|
@test_users = Koala::Facebook::TestUsers.new({:app_access_token => @app_access_token, :app_id => @app_id})
|
|
172
229
|
@network = []
|
|
173
230
|
|
|
174
|
-
if
|
|
231
|
+
if KoalaTest.mock_interface?
|
|
175
232
|
id_counter = 999999900
|
|
176
233
|
@test_users.stub!(:create).and_return do
|
|
177
234
|
id_counter += 1
|
|
@@ -183,16 +240,6 @@ describe "Koala::Facebook::TestUsers" do
|
|
|
183
240
|
end
|
|
184
241
|
|
|
185
242
|
describe "tests that create users" do
|
|
186
|
-
before :each do
|
|
187
|
-
test_users = Koala::Facebook::TestUsers.new({:app_access_token => @app_access_token, :app_id => @app_id})
|
|
188
|
-
test_users.delete_all
|
|
189
|
-
end
|
|
190
|
-
|
|
191
|
-
after :each do
|
|
192
|
-
test_users = Koala::Facebook::TestUsers.new({:app_access_token => @app_access_token, :app_id => @app_id})
|
|
193
|
-
test_users.delete_all
|
|
194
|
-
end
|
|
195
|
-
|
|
196
243
|
it "should create a 5 person network" do
|
|
197
244
|
size = 5
|
|
198
245
|
@network = @test_users.create_network(size)
|
|
@@ -201,10 +248,11 @@ describe "Koala::Facebook::TestUsers" do
|
|
|
201
248
|
end
|
|
202
249
|
end
|
|
203
250
|
|
|
204
|
-
it "
|
|
205
|
-
|
|
251
|
+
it "has no built-in network size limit" do
|
|
252
|
+
times = 100
|
|
253
|
+
@test_users.should_receive(:create).exactly(times).times
|
|
206
254
|
@test_users.stub!(:befriend)
|
|
207
|
-
@network = @test_users.create_network(
|
|
255
|
+
@network = @test_users.create_network(times)
|
|
208
256
|
end
|
|
209
257
|
|
|
210
258
|
it "should pass on the installed and permissions parameters to create" do
|
|
@@ -218,4 +266,4 @@ describe "Koala::Facebook::TestUsers" do
|
|
|
218
266
|
|
|
219
267
|
end # when creating network
|
|
220
268
|
end
|
|
221
|
-
end # describe Koala TestUsers
|
|
269
|
+
end # describe Koala TestUsers
|