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.
Files changed (70) hide show
  1. data/lib/singly.rb +5 -1
  2. data/lib/singly/account.rb +4 -4
  3. data/lib/singly/api/profiles.rb +5 -2
  4. data/lib/singly/api/profiles/service.rb +6 -3
  5. data/lib/singly/api/services.rb +4 -2
  6. data/lib/singly/api/services/37signals.rb +0 -1
  7. data/lib/singly/api/services/bodymedia.rb +1 -2
  8. data/lib/singly/api/services/dropbox.rb +1 -2
  9. data/lib/singly/api/services/dwolla.rb +1 -2
  10. data/lib/singly/api/services/endpoint.rb +1 -1
  11. data/lib/singly/api/services/facebook.rb +1 -2
  12. data/lib/singly/api/services/fitbit.rb +1 -2
  13. data/lib/singly/api/services/flickr.rb +1 -4
  14. data/lib/singly/api/services/foursquare.rb +1 -2
  15. data/lib/singly/api/services/gcal.rb +1 -2
  16. data/lib/singly/api/services/gcontacts.rb +1 -2
  17. data/lib/singly/api/services/gdocs.rb +1 -2
  18. data/lib/singly/api/services/github.rb +1 -2
  19. data/lib/singly/api/services/gmail.rb +1 -2
  20. data/lib/singly/api/services/google.rb +1 -2
  21. data/lib/singly/api/services/gplus.rb +1 -2
  22. data/lib/singly/api/services/imgur.rb +1 -2
  23. data/lib/singly/api/services/instagram.rb +1 -2
  24. data/lib/singly/api/services/klout.rb +1 -2
  25. data/lib/singly/api/services/linkedin.rb +1 -2
  26. data/lib/singly/api/services/meetup.rb +1 -2
  27. data/lib/singly/api/services/paypal.rb +1 -2
  28. data/lib/singly/api/services/picasa.rb +1 -2
  29. data/lib/singly/api/services/rdio.rb +1 -2
  30. data/lib/singly/api/services/reddit.rb +1 -2
  31. data/lib/singly/api/services/runkeeper.rb +1 -2
  32. data/lib/singly/api/services/service.rb +9 -31
  33. data/lib/singly/api/services/shutterfly.rb +1 -2
  34. data/lib/singly/api/services/soundcloud.rb +1 -2
  35. data/lib/singly/api/services/stocktwits.rb +1 -2
  36. data/lib/singly/api/services/tout.rb +1 -2
  37. data/lib/singly/api/services/tumblr.rb +1 -2
  38. data/lib/singly/api/services/twitter.rb +1 -2
  39. data/lib/singly/api/services/withings.rb +1 -2
  40. data/lib/singly/api/services/wordpress.rb +1 -2
  41. data/lib/singly/api/services/yammer.rb +1 -2
  42. data/lib/singly/api/services/youtube.rb +1 -2
  43. data/lib/singly/api/services/zeo.rb +1 -2
  44. data/lib/singly/endpoint.rb +52 -43
  45. data/lib/singly/error.rb +6 -4
  46. data/lib/singly/http.rb +7 -8
  47. data/lib/version.rb +1 -1
  48. data/spec/integration/account/apply_spec.rb +36 -0
  49. data/spec/integration/account/delete_spec.rb +23 -0
  50. data/spec/integration/account/friends_spec.rb +51 -0
  51. data/spec/integration/account/id_spec.rb +23 -0
  52. data/spec/integration/account/merge_spec.rb +14 -0
  53. data/spec/integration/account/profile_spec.rb +14 -0
  54. data/spec/integration/account/profiles_spec.rb +64 -0
  55. data/spec/integration/account/proxy_spec.rb +43 -0
  56. data/spec/integration/account/services_spec.rb +62 -0
  57. data/spec/integration/account/types_spec.rb +57 -0
  58. data/spec/integration/api_spec.rb +77 -0
  59. data/spec/singly/account_spec.rb +8 -8
  60. data/spec/singly/endpoint_spec.rb +53 -45
  61. data/spec/singly/error_spec.rb +21 -13
  62. data/spec/singly/http_spec.rb +26 -13
  63. data/spec/singly_spec.rb +1 -1
  64. data/spec/spec_helper.rb +6 -0
  65. data/spec/vcr_cassettes/{http_fetch_with_api_error.yml → singly/http_fetch_with_api_error.yml} +3 -3
  66. data/spec/vcr_cassettes/{http_fetch_with_json_response.yml → singly/http_fetch_with_json_response.yml} +2 -2
  67. data/spec/vcr_cassettes/{http_fetch_with_non_json_response.yml → singly/http_fetch_with_non_json_response.yml} +2 -2
  68. metadata +30 -12
  69. data/spec/integration/auth_spec.rb +0 -14
  70. data/spec/singly/api/auth_spec.rb +0 -8
@@ -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
- let(:response) { Typhoeus::Response.new({
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, "Response timed out after 2.01 seconds. http://www.example.com/timemeout")
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 {\"timehop\":\"is_amazing\"} http://www.example.com/badresponse")
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
@@ -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) } # Yeah, this is kinda
20
- before { Typhoeus::Request.stub(:send).with(any_args).and_return(timed_out_response)} # fragile, but how do
21
- it "should raise timeout error" do # I otherwise enforce
22
- expect{ http.fetch(:get, "/any_damn_thing") }.to raise_error(Singly::TimeoutError) # a real timeout?
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
- VCR.use_cassette "http_fetch_with_api_error" do
29
- http.fetch(:get, "/no_such_endpoint")
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
- VCR.use_cassette "http_fetch_with_json_response" do
37
- http.fetch(:get, "/services")
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
- VCR.use_cassette "http_fetch_with_non_json_response" do
46
- http.fetch(:get, "/enoch") # /enoch is the endpoint used internally at singly to check
47
- end # service health. It is not documented and likely to change.
48
- } # But for the purposes of testing non-json responses without
49
- it { should == "true" } # having to supply auth params, it's perfect.
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
@@ -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.query_params[:urls].should == "services/facebook,auth/instagram/apply" }
50
+ it { subject.options[:params][:urls].should == "services/facebook,auth/instagram/apply" }
51
51
  end
52
52
  end
53
53
  end
@@ -24,4 +24,10 @@ VCR.configure do |config|
24
24
  config.cassette_library_dir = 'spec/vcr_cassettes'
25
25
  config.hook_into :typhoeus
26
26
  # config.allow_http_connections_when_no_cassette = true
27
+ end
28
+
29
+ def vcr(cassette)
30
+ VCR.use_cassette(cassette) do
31
+ yield
32
+ end
27
33
  end
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  http_interactions:
3
3
  - request:
4
- method: get
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
- - Sun, 17 Feb 2013 03:22:16 GMT
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: Sun, 17 Feb 2013 03:22:15 GMT
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
- - Sun, 17 Feb 2013 03:22:16 GMT
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: Sun, 17 Feb 2013 03:22:15 GMT
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
- - Sun, 17 Feb 2013 03:22:16 GMT
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: Sun, 17 Feb 2013 03:22:16 GMT
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.0
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-22 00:00:00.000000000 Z
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/auth_spec.rb
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/auth_spec.rb
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
@@ -1,8 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Singly::Auth do
4
- describe "#merge" do
5
- subject { Singly::Auth.new.merge(source: "abc", dest: "123").url }
6
- it { should == "https://api.singly.com/v0/auth/merge?dest=123&source=abc" }
7
- end
8
- end