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
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Singly.account(:access_token).merge" do
4
+ let(:account) { Singly.account("TOKEN_STUB") }
5
+ describe "GET /auth/merge" do
6
+ subject { account.merge("SOURCE_TOKEN") }
7
+ it { subject.validate.should == true }
8
+ it { subject.path.should == "/auth/merge" }
9
+ it { subject.options.should include(
10
+ method: :get,
11
+ params: {source: "SOURCE_TOKEN", dest: "TOKEN_STUB"}
12
+ )}
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Singly.account(:access_token).profile" do
4
+ let(:account) { Singly.account("TOKEN_STUB") }
5
+ describe "GET /profile" do
6
+ subject { account.profile }
7
+ it { subject.validate.should == true }
8
+ it { subject.path.should == "/profile" }
9
+ it { subject.options.should include(
10
+ method: :get,
11
+ params: { access_token: "TOKEN_STUB" }
12
+ )}
13
+ end
14
+ end
@@ -0,0 +1,64 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Singly.account(:access_token).profiles" do
4
+ let(:account) { Singly.account("TOKEN_STUB") }
5
+ describe "GET /profiles" do
6
+ subject { account.profiles }
7
+ it { subject.validate.should == true }
8
+ it { subject.path.should == "/profiles" }
9
+ it { subject.options.should include(
10
+ method: :get,
11
+ params: { access_token: "TOKEN_STUB" }
12
+ )}
13
+ end
14
+ describe "GET /profiles with optional params" do
15
+ subject { account.profiles(data: true, verify: true) }
16
+ it { subject.validate.should == true }
17
+ it { subject.path.should == "/profiles" }
18
+ it { subject.options.should include(
19
+ method: :get,
20
+ params: {
21
+ access_token: "TOKEN_STUB",
22
+ data: true,
23
+ verify: true
24
+ }
25
+ )}
26
+ end
27
+ describe "GET /profiles/:service" do
28
+ subject { account.profiles.foursquare }
29
+ it { subject.validate.should == true }
30
+ it { subject.path.should == "/profiles/foursquare" }
31
+ it { subject.options.should include(
32
+ method: :get,
33
+ params: { access_token: "TOKEN_STUB" }
34
+ )}
35
+ end
36
+ describe "GET /profiles/self" do
37
+ subject { account.profiles.self }
38
+ it { subject.validate.should == true }
39
+ it { subject.path.should == "/profiles/self" }
40
+ it { subject.options.should include(
41
+ method: :get,
42
+ params: { access_token: "TOKEN_STUB" }
43
+ )}
44
+ end
45
+ describe "POST /profiles/self with data" do
46
+ subject { account.profiles.self(x: 1, y: {z: 3}) }
47
+ it { subject.validate.should == true }
48
+ it { subject.path.should == "/profiles/self" }
49
+ it { subject.options.should include(
50
+ method: :post,
51
+ params: { access_token: "TOKEN_STUB" },
52
+ body: { x: 1, y: { z: 3 } }
53
+ )}
54
+ end
55
+ describe "DELETE /profiles" do
56
+ subject { account.profiles.delete }
57
+ it { subject.validate.should == true }
58
+ it { subject.path.should == "/profiles" }
59
+ it { subject.options.should include(
60
+ method: :delete,
61
+ params: { access_token: "TOKEN_STUB" }
62
+ )}
63
+ end
64
+ end
@@ -0,0 +1,43 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Singly.account(:access_token).proxy" do
4
+ let(:account) { Singly.account("TOKEN_STUB") }
5
+ describe "GET /proxy/:service/:path" do
6
+ subject { account.proxy.thirtysevensignals(:get, "some/path/123", {a: :b}) }
7
+ it { subject.validate.should == true }
8
+ it { subject.path.should == "/proxy/37signals/some%2Fpath%2F123" }
9
+ it { subject.options.should include(
10
+ method: :get,
11
+ params: { access_token: "TOKEN_STUB", a: :b }
12
+ )}
13
+ end
14
+ describe "PUT /proxy/:service/:path" do
15
+ subject { account.proxy.yammer(:put, "some/path/123", {a: :b}) }
16
+ it { subject.validate.should == true }
17
+ it { subject.path.should == "/proxy/yammer/some%2Fpath%2F123" }
18
+ it { subject.options.should include(
19
+ method: :put,
20
+ params: { access_token: "TOKEN_STUB" },
21
+ body: { a: :b }
22
+ )}
23
+ end
24
+ describe "POST /proxy/:service/:path" do
25
+ subject { account.proxy.zeo(:post, "some/path/123", {a: :b}) }
26
+ it { subject.validate.should == true }
27
+ it { subject.path.should == "/proxy/zeo/some%2Fpath%2F123" }
28
+ it { subject.options.should include(
29
+ method: :post,
30
+ params: { access_token: "TOKEN_STUB" },
31
+ body: { a: :b }
32
+ )}
33
+ end
34
+ describe "DELETE /proxy/:service/:path" do
35
+ subject { account.proxy.tumblr(:delete, "some/path/123", {a: :b}) }
36
+ it { subject.validate.should == true }
37
+ it { subject.path.should == "/proxy/tumblr/some%2Fpath%2F123" }
38
+ it { subject.options.should include(
39
+ method: :delete,
40
+ params: { access_token: "TOKEN_STUB", a: :b },
41
+ )}
42
+ end
43
+ end
@@ -0,0 +1,62 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Singly.account(:access_token).services" do
4
+ let(:account) { Singly.account("TOKEN_STUB") }
5
+ describe "GET /services/:service" do
6
+ subject { account.services.dwolla }
7
+ it { subject.validate.should == true }
8
+ it { subject.path.should == "/services/dwolla" }
9
+ it { subject.options.should include(
10
+ method: :get,
11
+ params: { access_token: "TOKEN_STUB" }
12
+ )}
13
+ end
14
+ describe "GET /services/:service/:endpoint" do
15
+ subject { account.services.fitbit.devices }
16
+ it { subject.validate.should == true }
17
+ it { subject.path.should == "/services/fitbit/devices" }
18
+ it { subject.options.should include(
19
+ method: :get,
20
+ params: { access_token: "TOKEN_STUB" }
21
+ )}
22
+ end
23
+ describe "GET /services/:service/:endpoint with optional params" do
24
+ subject { account.services.facebook.photos({
25
+ fields: "map.oembed",
26
+ limit: 200,
27
+ :since => 1361669948000,
28
+ :until => 1361679948000,
29
+ near: "40.7361,73.9901",
30
+ within: "1",
31
+ q: "Timehop BOOM",
32
+ participants: "self",
33
+ map: true
34
+ }) }
35
+ it { subject.validate.should == true }
36
+ it { subject.path.should == "/services/facebook/photos" }
37
+ it { subject.options.should include(
38
+ method: :get,
39
+ params: {
40
+ access_token: "TOKEN_STUB",
41
+ fields: "map.oembed",
42
+ limit: 200,
43
+ :since => 1361669948000,
44
+ :until => 1361679948000,
45
+ near: "40.7361,73.9901",
46
+ within: "1",
47
+ q: "Timehop BOOM",
48
+ participants: "self",
49
+ map: true
50
+ }
51
+ )}
52
+ end
53
+ describe "GET /services/:service/:endpoint/:id" do
54
+ subject { account.services.twitter.tweets(id: "1234@5/6") }
55
+ it { subject.validate.should == true }
56
+ it { subject.path.should == "/services/twitter/tweets/1234%405%2F6" }
57
+ it { subject.options.should include(
58
+ method: :get,
59
+ params: { access_token: "TOKEN_STUB" }
60
+ )}
61
+ end
62
+ end
@@ -0,0 +1,57 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Singly.account(:access_token).types" do
4
+ let(:account) { Singly.account("TOKEN_STUB") }
5
+ describe "GET /types" do
6
+ subject { account.types }
7
+ it { subject.validate.should == true }
8
+ it { subject.path.should == "/types" }
9
+ it { subject.options.should include(
10
+ method: :get,
11
+ params: { access_token: "TOKEN_STUB" }
12
+ )}
13
+ end
14
+ describe "GET /types/:type" do
15
+ subject { account.types.photos }
16
+ it { subject.validate.should == true }
17
+ it { subject.path.should == "/types/photos" }
18
+ it { subject.options.should include(
19
+ method: :get,
20
+ params: { access_token: "TOKEN_STUB" }
21
+ )}
22
+ end
23
+ describe "GET /types/:type with optional params" do
24
+ subject { account.types.all({
25
+ fields: "map.oembed",
26
+ limit: 200,
27
+ :since => 1361669948000,
28
+ :until => 1361679948000,
29
+ near: "40.7361,73.9901",
30
+ within: "1",
31
+ q: "Timehop BOOM",
32
+ participants: "self",
33
+ map: true,
34
+ dedup: true,
35
+ services: "facebook,foursquare"
36
+ }) }
37
+ it { subject.validate.should == true }
38
+ it { subject.path.should == "/types/all" }
39
+ it { subject.options.should include(
40
+ method: :get,
41
+ params: {
42
+ access_token: "TOKEN_STUB",
43
+ fields: "map.oembed",
44
+ limit: 200,
45
+ :since => 1361669948000,
46
+ :until => 1361679948000,
47
+ near: "40.7361,73.9901",
48
+ within: "1",
49
+ q: "Timehop BOOM",
50
+ participants: "self",
51
+ map: true,
52
+ dedup: true,
53
+ services: "facebook,foursquare"
54
+ }
55
+ )}
56
+ end
57
+ end
@@ -0,0 +1,77 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Integration" do
4
+ context "For an existing account" do
5
+ let(:api) { Singly.account("TOKEN_STUB") }
6
+ describe "GET /profile" do
7
+ subject { api.profile }
8
+ it { subject.validate.should == true }
9
+ it { subject.path.should == "/profile" }
10
+ it { subject.options.should include(
11
+ method: :get,
12
+ params: { access_token: "TOKEN_STUB" }
13
+ )}
14
+ end
15
+ describe "GET /profiles" do
16
+ subject { api.profiles }
17
+ it { subject.validate.should == true }
18
+ it { subject.path.should == "/profiles" }
19
+ it { subject.options.should include(
20
+ method: :get,
21
+ params: { access_token: "TOKEN_STUB" }
22
+ )}
23
+ end
24
+ describe "GET /profiles with optional params" do
25
+ subject { api.profiles(data: true, verify: true) }
26
+ it { subject.validate.should == true }
27
+ it { subject.path.should == "/profiles" }
28
+ it { subject.options.should include(
29
+ method: :get,
30
+ params: {
31
+ access_token: "TOKEN_STUB",
32
+ data: true,
33
+ verify: true
34
+ }
35
+ )}
36
+ end
37
+ describe "GET /profiles/:service" do
38
+ subject { api.profiles.foursquare }
39
+ it { subject.validate.should == true }
40
+ it { subject.path.should == "/profiles/foursquare" }
41
+ it { subject.options.should include(
42
+ method: :get,
43
+ params: { access_token: "TOKEN_STUB" }
44
+ )}
45
+ end
46
+ describe "GET /profiles/self" do
47
+ subject { api.profiles.self }
48
+ it { subject.validate.should == true }
49
+ it { subject.path.should == "/profiles/self" }
50
+ it { subject.options.should include(
51
+ method: :get,
52
+ params: { access_token: "TOKEN_STUB" }
53
+ )}
54
+ end
55
+ describe "POST /profiles/self with data" do
56
+ subject { api.profiles.self(x: 1, y: {z: 3}) }
57
+ it { subject.validate.should == true }
58
+ it { subject.path.should == "/profiles/self" }
59
+ it { subject.options.should include(
60
+ method: :post,
61
+ params: { access_token: "TOKEN_STUB" },
62
+ body: { x: 1, y: { z: 3 } }
63
+ )}
64
+ end
65
+ describe "DELETE /profiles" do
66
+ subject { api.profiles.delete }
67
+ it { subject.validate.should == true }
68
+ it { subject.path.should == "/profiles" }
69
+ it { subject.options.should include(
70
+ method: :delete,
71
+ params: { access_token: "TOKEN_STUB" }
72
+ )}
73
+ end
74
+ end
75
+ context "No Account" do
76
+ end
77
+ end
@@ -41,7 +41,7 @@ describe Singly::Account do
41
41
  subject { account.profiles(data: true, verify: true) }
42
42
  it { subject.class.should == Singly::Profiles }
43
43
  it { subject.validate.should be_true }
44
- it { subject.query_params.should include(data: true, verify: true) }
44
+ it { subject.options[:params].should include(data: true, verify: true) }
45
45
  end
46
46
  end
47
47
  describe "#types" do
@@ -64,7 +64,7 @@ describe Singly::Account do
64
64
  subject { account.id("abc123", map: true) }
65
65
  it { subject.class.should == Singly::Id }
66
66
  it { subject.validate.should be_true }
67
- it { subject.query_params.should include(map: true) }
67
+ it { subject.options[:params].should include(map: true) }
68
68
  end
69
69
  end
70
70
  describe "#delete" do
@@ -72,20 +72,20 @@ describe Singly::Account do
72
72
  subject { account.delete(:facebook) }
73
73
  it { subject.class.should == Singly::Profiles::DeleteService }
74
74
  it { subject.validate.should be_true }
75
- it { subject.route_params.should include(service: "facebook") }
75
+ it { subject.path.should == "/profiles/facebook" }
76
76
  end
77
77
  context "where we delete a specific profile by id" do
78
- subject { account.delete(:facebook, 987654321) }
78
+ subject { account.delete(:dropbox, 987654321) }
79
79
  it { subject.class.should == Singly::Profiles::DeleteProfile }
80
80
  it { subject.validate.should be_true }
81
- it { subject.route_params.should include(service: "facebook", id: "987654321") }
81
+ it { subject.path.should == "/profiles/987654321@dropbox" }
82
82
  end
83
83
  end
84
84
  describe "#merge" do
85
85
  subject { account.merge("fake_source_access_token") }
86
86
  it { subject.class.should == Singly::Auth::Merge }
87
87
  it { subject.validate.should be_true }
88
- it { subject.query_params.should include(
88
+ it { subject.options[:params].should include(
89
89
  source: "fake_source_access_token",
90
90
  dest: "fake_access_token"
91
91
  ) }
@@ -96,13 +96,13 @@ describe Singly::Account do
96
96
  subject { account.apply(:instagram, token: "tokin") }
97
97
  it { subject.class.should == Singly::Auth::Service::Oauth2Apply }
98
98
  it { subject.validate.should be_true }
99
- it { subject.query_params.should include(account: "fake_account_id") }
99
+ it { subject.options[:params].should include(account: "fake_account_id") }
100
100
  end
101
101
  context "with an oauth1 service" do
102
102
  subject { account.apply(:flickr, token: "tokin", token_secret: "shhh_tokin") }
103
103
  it { subject.class.should == Singly::Auth::Service::Oauth1Apply }
104
104
  it { subject.validate.should be_true }
105
- it { subject.query_params.should include(account: "fake_account_id") }
105
+ it { subject.options[:params].should include(account: "fake_account_id") }
106
106
  end
107
107
  end
108
108
  end
@@ -1,99 +1,107 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Singly::Endpoint do
4
- class DummyEndpoint
4
+ class DummyGetEndpoint
5
5
  include Singly::Endpoint
6
- endpoint :get, "/dummy/:service/:id@:type", required: [:a, :b], optional: [:c, :d]
6
+ endpoint :get, "/dummy/:service/:id@:type", required: [:access_token], optional: [:field1]
7
+ end
8
+ class DummyPostEndpoint
9
+ include Singly::Endpoint
10
+ endpoint :post, "/dummy/post/:here", required: [:access_token], optional: [:field1]
7
11
  end
8
12
  context "class methods" do
9
- describe ".type" do
10
- subject { DummyEndpoint.type }
13
+ describe ".http_method" do
14
+ subject { DummyGetEndpoint.http_method }
11
15
  it { should == :get }
12
16
  end
13
17
  describe ".route" do
14
- subject { DummyEndpoint.route }
18
+ subject { DummyGetEndpoint.route }
15
19
  it { should == "/dummy/:service/:id@:type" }
16
20
  end
17
- describe ".required_route_params" do
18
- subject { DummyEndpoint.required_route_params }
19
- it { should == [:service, :id, :type] }
20
- end
21
21
  describe ".required_params" do
22
- subject { DummyEndpoint.required_params }
23
- it { should == [:a, :b] }
22
+ subject { DummyGetEndpoint.required_params }
23
+ it { should == [:access_token] }
24
24
  end
25
25
  describe ".optional_params" do
26
- subject { DummyEndpoint.optional_params }
27
- it { should == [:c, :d] }
26
+ subject { DummyGetEndpoint.optional_params }
27
+ it { should == [:field1] }
28
28
  end
29
29
  end
30
30
  context "instance methods" do
31
31
  describe "#fetch" do
32
- let(:endpoint) { DummyEndpoint.new(params) }
32
+ let(:endpoint) { DummyGetEndpoint.new(params) }
33
33
  context "with valid params" do
34
34
  subject { endpoint.fetch }
35
35
  let(:params) { {
36
36
  service: :timehop,
37
37
  id: 123,
38
38
  type: "just_my",
39
- a: "a",
40
- b: "b",
41
- c: "c"
39
+ access_token: "at",
40
+ field1: "a field"
41
+ } }
42
+ let(:result) { double(:json) }
43
+ before { Singly::Http.should_receive(:fetch).with("/dummy/timehop/123@just_my", {
44
+ method: :get,
45
+ params: {access_token: "at", field1: "a field"},
46
+ timeout: 2
47
+ }).and_return(result) }
48
+ it { should == result }
49
+ end
50
+ context "with post endpoint" do
51
+ let(:endpoint) { DummyPostEndpoint.new(params) }
52
+ subject { endpoint.fetch(timeout: 3 ) }
53
+ let(:params) { {
54
+ here: "ya_go",
55
+ access_token: "at",
56
+ extra: "field"
42
57
  } }
43
58
  let(:result) { double(:json) }
44
- before { Singly::Http.should_receive(:fetch).with(:get, "/dummy/timehop/123@just_my", {a: "a", b: "b", c: "c"}).and_return(result) }
59
+ before { Singly::Http.should_receive(:fetch).with("/dummy/post/ya_go", {
60
+ :method=>:post,
61
+ :timeout=>3,
62
+ :params=>{:access_token=>"at"},
63
+ :body=>{:extra=>"field"}
64
+ }).and_return(result) }
45
65
  it { should == result }
46
66
  end
47
67
  context "with missing required params" do
48
68
  let(:params) { {
49
69
  service: :timehop,
50
70
  id: 123,
51
- type: "just_my",
52
- b: "b",
53
- c: "c"
71
+ type: "just_my"
54
72
  } }
55
- it { expect{endpoint.fetch}.to raise_error(Singly::Error, "y u no has query params :a???") }
73
+ it { expect{endpoint.fetch}.to raise_error(Singly::Error, "y u no has required params :access_token???") }
56
74
  end
57
75
  context "with missing route params" do
58
76
  let(:params) { {
59
77
  service: :timehop,
60
- a: "a",
61
- b: "b"
78
+ access_token: "at",
79
+ id: "123"
62
80
  } }
63
- it { expect{endpoint.fetch}.to raise_error(Singly::Error, "y u no has route params :id, :type???") }
81
+ it { expect{endpoint.fetch}.to raise_error(Singly::Error, "y u no has all route params: /dummy/timehop/123@:type???") }
64
82
  end
65
83
  end
66
84
  describe "#url" do
67
- let(:endpoint) { DummyEndpoint.new(params) }
85
+ let(:endpoint) { DummyPostEndpoint.new(params) }
68
86
  context "with valid params" do
69
87
  subject { endpoint.url }
70
88
  let(:params) { {
71
- service: :timehop,
72
- id: 123,
73
- type: "just_my",
74
- a: "a",
75
- b: :b,
76
- c: "c"
89
+ here: "ya_go",
90
+ access_token: "at"
77
91
  } }
78
- it { should == "https://api.singly.com/v0/dummy/timehop/123@just_my?a=a&b=b&c=c" }
92
+ it { should == "https://api.singly.com/v0/dummy/post/ya_go?access_token=at" }
79
93
  end
80
- context "with missing required params" do
94
+ context "with missing route params" do
81
95
  let(:params) { {
82
- service: :timehop,
83
- id: 123,
84
- type: "just_my",
85
- b: "b",
86
- c: "c"
96
+ access_token: "at"
87
97
  } }
88
- it { expect{endpoint.fetch}.to raise_error(Singly::Error, "y u no has query params :a???") }
98
+ it { expect{endpoint.fetch}.to raise_error(Singly::Error, "y u no has all route params: /dummy/post/:here???") }
89
99
  end
90
- context "with missing route params" do
100
+ context "with missing required params" do
91
101
  let(:params) { {
92
- service: :timehop,
93
- a: "a",
94
- b: "b"
102
+ here: "ya_go"
95
103
  } }
96
- it { expect{endpoint.fetch}.to raise_error(Singly::Error, "y u no has route params :id, :type???") }
104
+ it { expect{endpoint.fetch}.to raise_error(Singly::Error, "y u no has required params :access_token???") }
97
105
  end
98
106
  end
99
107
  end