singly 0.1.0 → 0.1.1
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/lib/singly.rb +5 -1
- data/lib/singly/account.rb +4 -4
- data/lib/singly/api/profiles.rb +5 -2
- data/lib/singly/api/profiles/service.rb +6 -3
- data/lib/singly/api/services.rb +4 -2
- data/lib/singly/api/services/37signals.rb +0 -1
- data/lib/singly/api/services/bodymedia.rb +1 -2
- data/lib/singly/api/services/dropbox.rb +1 -2
- data/lib/singly/api/services/dwolla.rb +1 -2
- data/lib/singly/api/services/endpoint.rb +1 -1
- data/lib/singly/api/services/facebook.rb +1 -2
- data/lib/singly/api/services/fitbit.rb +1 -2
- data/lib/singly/api/services/flickr.rb +1 -4
- data/lib/singly/api/services/foursquare.rb +1 -2
- data/lib/singly/api/services/gcal.rb +1 -2
- data/lib/singly/api/services/gcontacts.rb +1 -2
- data/lib/singly/api/services/gdocs.rb +1 -2
- data/lib/singly/api/services/github.rb +1 -2
- data/lib/singly/api/services/gmail.rb +1 -2
- data/lib/singly/api/services/google.rb +1 -2
- data/lib/singly/api/services/gplus.rb +1 -2
- data/lib/singly/api/services/imgur.rb +1 -2
- data/lib/singly/api/services/instagram.rb +1 -2
- data/lib/singly/api/services/klout.rb +1 -2
- data/lib/singly/api/services/linkedin.rb +1 -2
- data/lib/singly/api/services/meetup.rb +1 -2
- data/lib/singly/api/services/paypal.rb +1 -2
- data/lib/singly/api/services/picasa.rb +1 -2
- data/lib/singly/api/services/rdio.rb +1 -2
- data/lib/singly/api/services/reddit.rb +1 -2
- data/lib/singly/api/services/runkeeper.rb +1 -2
- data/lib/singly/api/services/service.rb +9 -31
- data/lib/singly/api/services/shutterfly.rb +1 -2
- data/lib/singly/api/services/soundcloud.rb +1 -2
- data/lib/singly/api/services/stocktwits.rb +1 -2
- data/lib/singly/api/services/tout.rb +1 -2
- data/lib/singly/api/services/tumblr.rb +1 -2
- data/lib/singly/api/services/twitter.rb +1 -2
- data/lib/singly/api/services/withings.rb +1 -2
- data/lib/singly/api/services/wordpress.rb +1 -2
- data/lib/singly/api/services/yammer.rb +1 -2
- data/lib/singly/api/services/youtube.rb +1 -2
- data/lib/singly/api/services/zeo.rb +1 -2
- data/lib/singly/endpoint.rb +52 -43
- data/lib/singly/error.rb +6 -4
- data/lib/singly/http.rb +7 -8
- data/lib/version.rb +1 -1
- data/spec/integration/account/apply_spec.rb +36 -0
- data/spec/integration/account/delete_spec.rb +23 -0
- data/spec/integration/account/friends_spec.rb +51 -0
- data/spec/integration/account/id_spec.rb +23 -0
- data/spec/integration/account/merge_spec.rb +14 -0
- data/spec/integration/account/profile_spec.rb +14 -0
- data/spec/integration/account/profiles_spec.rb +64 -0
- data/spec/integration/account/proxy_spec.rb +43 -0
- data/spec/integration/account/services_spec.rb +62 -0
- data/spec/integration/account/types_spec.rb +57 -0
- data/spec/integration/api_spec.rb +77 -0
- data/spec/singly/account_spec.rb +8 -8
- data/spec/singly/endpoint_spec.rb +53 -45
- data/spec/singly/error_spec.rb +21 -13
- data/spec/singly/http_spec.rb +26 -13
- data/spec/singly_spec.rb +1 -1
- data/spec/spec_helper.rb +6 -0
- data/spec/vcr_cassettes/{http_fetch_with_api_error.yml → singly/http_fetch_with_api_error.yml} +3 -3
- data/spec/vcr_cassettes/{http_fetch_with_json_response.yml → singly/http_fetch_with_json_response.yml} +2 -2
- data/spec/vcr_cassettes/{http_fetch_with_non_json_response.yml → singly/http_fetch_with_non_json_response.yml} +2 -2
- metadata +30 -12
- data/spec/integration/auth_spec.rb +0 -14
- data/spec/singly/api/auth_spec.rb +0 -8
data/spec/singly/error_spec.rb
CHANGED
@@ -11,30 +11,38 @@ describe Singly::Error do
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
describe Singly::TimeoutError do
|
14
|
+
let(:response) { Typhoeus::Response.new({
|
15
|
+
return_code: :operation_timedout,
|
16
|
+
total_time: 2.01,
|
17
|
+
effective_url: "http://www.example.com/timemeout"
|
18
|
+
}) }
|
14
19
|
describe "#initialize" do
|
15
|
-
|
16
|
-
return_code: :operation_timedout,
|
17
|
-
total_time: 2.01,
|
18
|
-
effective_url: "http://www.example.com/timemeout"
|
19
|
-
}) }
|
20
|
-
it "should raise a timeout erro " do
|
20
|
+
it "should raise a timeout error" do
|
21
21
|
expect{
|
22
22
|
raise Singly::TimeoutError.new(response)
|
23
|
-
}.to raise_error(Singly::TimeoutError, "
|
23
|
+
}.to raise_error(Singly::TimeoutError, "Timed out after 2.01 seconds")
|
24
24
|
end
|
25
25
|
end
|
26
|
+
describe "#response" do
|
27
|
+
subject { Singly::TimeoutError.new(response).response }
|
28
|
+
it { should == response }
|
29
|
+
end
|
26
30
|
end
|
27
31
|
describe Singly::ApiError do
|
32
|
+
let(:response) { Typhoeus::Response.new({
|
33
|
+
response_code: 400,
|
34
|
+
effective_url: "http://www.example.com/badresponse",
|
35
|
+
body: {"Timehop" => "BOOM"}.to_json
|
36
|
+
}) }
|
28
37
|
describe "#initialize" do
|
29
|
-
let(:response) { Typhoeus::Response.new({
|
30
|
-
response_code: 400,
|
31
|
-
effective_url: "http://www.example.com/badresponse",
|
32
|
-
body: {timehop: :is_amazing}.to_json
|
33
|
-
}) }
|
34
38
|
it "should raise an api error" do
|
35
39
|
expect{
|
36
40
|
raise Singly::ApiError.new(response)
|
37
|
-
}.to raise_error(Singly::ApiError, "400 {\"
|
41
|
+
}.to raise_error(Singly::ApiError, "HTTP 400 {\"Timehop\":\"BOOM\"}")
|
38
42
|
end
|
39
43
|
end
|
44
|
+
describe "#response" do
|
45
|
+
subject { Singly::ApiError.new(response).response }
|
46
|
+
it { should == response }
|
47
|
+
end
|
40
48
|
end
|
data/spec/singly/http_spec.rb
CHANGED
@@ -15,26 +15,39 @@ describe Singly::Http do
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
describe ".fetch" do
|
18
|
+
context "with options" do
|
19
|
+
subject { http.fetch("/derp", options)}
|
20
|
+
let(:options) { {method: :post, params: {a: :b}, body: {c: "d"}, timeout: 3} }
|
21
|
+
let(:request) { double(:request, {
|
22
|
+
run: double(:response, {
|
23
|
+
body: "true",
|
24
|
+
timed_out?: false,
|
25
|
+
code: 200
|
26
|
+
})
|
27
|
+
}) }
|
28
|
+
before { Typhoeus::Request.should_receive(:new).with("https://api.singly.com/v0/derp", options).and_return(request) }
|
29
|
+
it { should == "true" }
|
30
|
+
end
|
18
31
|
context "with timeout" do
|
19
|
-
let(:timed_out_response) { Typhoeus::Response.new(return_code: :operation_timedout) }
|
20
|
-
before { Typhoeus::Request.
|
21
|
-
it "should raise timeout error" do
|
22
|
-
expect{ http.fetch(
|
32
|
+
let(:timed_out_response) { Typhoeus::Response.new(return_code: :operation_timedout) }
|
33
|
+
before { Typhoeus::Request.stub_chain(:new, :run).with(any_args).and_return(timed_out_response)}
|
34
|
+
it "should raise timeout error" do
|
35
|
+
expect{ http.fetch("/any_damn_thing") }.to raise_error(Singly::TimeoutError)
|
23
36
|
end
|
24
37
|
end
|
25
38
|
context "with api error" do
|
26
39
|
it "should raise api error" do
|
27
40
|
expect {
|
28
|
-
|
29
|
-
http.fetch(
|
41
|
+
vcr("singly/http_fetch_with_api_error") do
|
42
|
+
http.fetch("/no_such_endpoint", method: :post)
|
30
43
|
end
|
31
44
|
}.to raise_error(Singly::ApiError)
|
32
45
|
end
|
33
46
|
end
|
34
47
|
context "with json response" do
|
35
48
|
subject {
|
36
|
-
|
37
|
-
http.fetch(
|
49
|
+
vcr("singly/http_fetch_with_json_response") do
|
50
|
+
http.fetch("/services")
|
38
51
|
end
|
39
52
|
}
|
40
53
|
let(:known_services) { ["fitbit", "gcontacts", "zeo", "foursquare", "meetup", "smugmug", "github", "dwolla", "yahoo", "runkeeper", "twitter", "google", "gdocs", "bodymedia", "dropbox", "37signals", "stocktwits", "yammer", "linkedin", "gplus", "picasa", "soundcloud", "gcal", "paypal", "tumblr", "rdio", "tout", "flickr", "youtube", "wordpress", "withings", "reddit", "imgur", "gmail", "instagram", "klout", "facebook", "shutterfly"] }
|
@@ -42,11 +55,11 @@ describe Singly::Http do
|
|
42
55
|
end
|
43
56
|
context "with non-json response" do
|
44
57
|
subject {
|
45
|
-
|
46
|
-
http.fetch(
|
47
|
-
end
|
48
|
-
}
|
49
|
-
it { should == "true" }
|
58
|
+
vcr("singly/http_fetch_with_non_json_response") do
|
59
|
+
http.fetch("/enoch") # /enoch is the endpoint used internally at singly to check
|
60
|
+
end # service health. It is not documented and likely to change.
|
61
|
+
} # But for the purposes of testing non-json responses without
|
62
|
+
it { should == "true" } # having to supply auth params, it's perfect.
|
50
63
|
end
|
51
64
|
end
|
52
65
|
end
|
data/spec/singly_spec.rb
CHANGED
@@ -47,7 +47,7 @@ describe Singly do
|
|
47
47
|
context "should provide a new multi endpoint" do
|
48
48
|
subject { Singly.multi(["services/facebook", "auth/instagram/apply"]) }
|
49
49
|
it { subject.class.should == Singly::Multi }
|
50
|
-
it { subject.
|
50
|
+
it { subject.options[:params][:urls].should == "services/facebook,auth/instagram/apply" }
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|
data/spec/spec_helper.rb
CHANGED
data/spec/vcr_cassettes/{http_fetch_with_api_error.yml → singly/http_fetch_with_api_error.yml}
RENAMED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
|
-
method:
|
4
|
+
method: post
|
5
5
|
uri: https://api.singly.com/v0/no_such_endpoint
|
6
6
|
body:
|
7
7
|
encoding: US-ASCII
|
@@ -24,7 +24,7 @@ http_interactions:
|
|
24
24
|
Content-Type:
|
25
25
|
- application/json; charset=utf-8
|
26
26
|
Date:
|
27
|
-
-
|
27
|
+
- Sat, 23 Feb 2013 23:38:27 GMT
|
28
28
|
X-Powered-By:
|
29
29
|
- Express
|
30
30
|
Content-Length:
|
@@ -35,5 +35,5 @@ http_interactions:
|
|
35
35
|
encoding: US-ASCII
|
36
36
|
string: ! '{"error":"This request requires a valid access_token."}'
|
37
37
|
http_version: '1.1'
|
38
|
-
recorded_at:
|
38
|
+
recorded_at: Sat, 23 Feb 2013 23:38:33 GMT
|
39
39
|
recorded_with: VCR 2.4.0
|
@@ -24,7 +24,7 @@ http_interactions:
|
|
24
24
|
Content-Type:
|
25
25
|
- application/json; charset=utf-8
|
26
26
|
Date:
|
27
|
-
-
|
27
|
+
- Sat, 23 Feb 2013 23:39:11 GMT
|
28
28
|
ETag:
|
29
29
|
- ! '"235545938"'
|
30
30
|
X-Powered-By:
|
@@ -98,5 +98,5 @@ http_interactions:
|
|
98
98
|
stream_likes page_likes"},{"name":"pages","frequency":86400,"class":"personal"}],"hasTestKeys":true},"shutterfly":{"name":"Shutterfly","desc":"Authentication
|
99
99
|
only","key":"Application Id","secret":"Shared Secret","icons":[{"height":16,"width":16,"source":"http://assets.singly.com/service-icons/16px/shutterfly.png"},{"height":24,"width":24,"source":"http://assets.singly.com/service-icons/24px/shutterfly.png"},{"height":32,"width":32,"source":"http://assets.singly.com/service-icons/32px/shutterfly.png"},{"height":48,"width":48,"source":"http://assets.singly.com/service-icons/48px/shutterfly.png"},{"height":64,"width":64,"source":"http://assets.singly.com/service-icons/64px/shutterfly.png"},{"height":128,"width":128,"source":"http://assets.singly.com/service-icons/128px/shutterfly.png"},{"height":256,"width":256,"source":"http://assets.singly.com/service-icons/256px/shutterfly.png"},{"height":512,"width":512,"source":"http://assets.singly.com/service-icons/512px/shutterfly.png"},{"height":1024,"width":1024,"source":"http://assets.singly.com/service-icons/1024px/shutterfly.png"}],"synclets":[{"name":"self","frequency":86400,"class":"core"},{"name":"photos","frequency":86400,"class":"personal"},{"name":"albums","frequency":86400,"class":"personal"}],"hasTestKeys":true}}'
|
100
100
|
http_version: '1.1'
|
101
|
-
recorded_at:
|
101
|
+
recorded_at: Sat, 23 Feb 2013 23:39:16 GMT
|
102
102
|
recorded_with: VCR 2.4.0
|
@@ -24,7 +24,7 @@ http_interactions:
|
|
24
24
|
Content-Type:
|
25
25
|
- application/json; charset=utf-8
|
26
26
|
Date:
|
27
|
-
-
|
27
|
+
- Sat, 23 Feb 2013 23:39:27 GMT
|
28
28
|
X-Powered-By:
|
29
29
|
- Express
|
30
30
|
Content-Length:
|
@@ -35,5 +35,5 @@ http_interactions:
|
|
35
35
|
encoding: US-ASCII
|
36
36
|
string: 'true'
|
37
37
|
http_version: '1.1'
|
38
|
-
recorded_at:
|
38
|
+
recorded_at: Sat, 23 Feb 2013 23:39:32 GMT
|
39
39
|
recorded_with: VCR 2.4.0
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: singly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
@@ -165,18 +165,27 @@ files:
|
|
165
165
|
- lib/singly/logger.rb
|
166
166
|
- lib/version.rb
|
167
167
|
- singly.gemspec
|
168
|
-
- spec/integration/
|
168
|
+
- spec/integration/account/apply_spec.rb
|
169
|
+
- spec/integration/account/delete_spec.rb
|
170
|
+
- spec/integration/account/friends_spec.rb
|
171
|
+
- spec/integration/account/id_spec.rb
|
172
|
+
- spec/integration/account/merge_spec.rb
|
173
|
+
- spec/integration/account/profile_spec.rb
|
174
|
+
- spec/integration/account/profiles_spec.rb
|
175
|
+
- spec/integration/account/proxy_spec.rb
|
176
|
+
- spec/integration/account/services_spec.rb
|
177
|
+
- spec/integration/account/types_spec.rb
|
178
|
+
- spec/integration/api_spec.rb
|
169
179
|
- spec/singly/account_spec.rb
|
170
|
-
- spec/singly/api/auth_spec.rb
|
171
180
|
- spec/singly/endpoint_spec.rb
|
172
181
|
- spec/singly/error_spec.rb
|
173
182
|
- spec/singly/http_spec.rb
|
174
183
|
- spec/singly/logger_spec.rb
|
175
184
|
- spec/singly_spec.rb
|
176
185
|
- spec/spec_helper.rb
|
177
|
-
- spec/vcr_cassettes/http_fetch_with_api_error.yml
|
178
|
-
- spec/vcr_cassettes/http_fetch_with_json_response.yml
|
179
|
-
- spec/vcr_cassettes/http_fetch_with_non_json_response.yml
|
186
|
+
- spec/vcr_cassettes/singly/http_fetch_with_api_error.yml
|
187
|
+
- spec/vcr_cassettes/singly/http_fetch_with_json_response.yml
|
188
|
+
- spec/vcr_cassettes/singly/http_fetch_with_non_json_response.yml
|
180
189
|
homepage: ''
|
181
190
|
licenses: []
|
182
191
|
post_install_message:
|
@@ -202,15 +211,24 @@ signing_key:
|
|
202
211
|
specification_version: 3
|
203
212
|
summary: See documentation at TBD
|
204
213
|
test_files:
|
205
|
-
- spec/integration/
|
214
|
+
- spec/integration/account/apply_spec.rb
|
215
|
+
- spec/integration/account/delete_spec.rb
|
216
|
+
- spec/integration/account/friends_spec.rb
|
217
|
+
- spec/integration/account/id_spec.rb
|
218
|
+
- spec/integration/account/merge_spec.rb
|
219
|
+
- spec/integration/account/profile_spec.rb
|
220
|
+
- spec/integration/account/profiles_spec.rb
|
221
|
+
- spec/integration/account/proxy_spec.rb
|
222
|
+
- spec/integration/account/services_spec.rb
|
223
|
+
- spec/integration/account/types_spec.rb
|
224
|
+
- spec/integration/api_spec.rb
|
206
225
|
- spec/singly/account_spec.rb
|
207
|
-
- spec/singly/api/auth_spec.rb
|
208
226
|
- spec/singly/endpoint_spec.rb
|
209
227
|
- spec/singly/error_spec.rb
|
210
228
|
- spec/singly/http_spec.rb
|
211
229
|
- spec/singly/logger_spec.rb
|
212
230
|
- spec/singly_spec.rb
|
213
231
|
- spec/spec_helper.rb
|
214
|
-
- spec/vcr_cassettes/http_fetch_with_api_error.yml
|
215
|
-
- spec/vcr_cassettes/http_fetch_with_json_response.yml
|
216
|
-
- spec/vcr_cassettes/http_fetch_with_non_json_response.yml
|
232
|
+
- spec/vcr_cassettes/singly/http_fetch_with_api_error.yml
|
233
|
+
- spec/vcr_cassettes/singly/http_fetch_with_json_response.yml
|
234
|
+
- spec/vcr_cassettes/singly/http_fetch_with_non_json_response.yml
|
@@ -1,14 +0,0 @@
|
|
1
|
-
require 'singly'
|
2
|
-
require 'yaml'
|
3
|
-
|
4
|
-
describe "Auth Integration" do
|
5
|
-
if ENV["CONFIG"]
|
6
|
-
config = YAML::load_file( ENV["CONFIG"] )
|
7
|
-
Singly.client_id = config[:singly][:client_id]
|
8
|
-
Singly.client_secret = config[:singly][:client_secret]
|
9
|
-
|
10
|
-
params = {token: config[:facebook][:token]}
|
11
|
-
r = Singly.auth.facebook.apply(params).fetch
|
12
|
-
puts r
|
13
|
-
end
|
14
|
-
end
|