buff 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/.travis.yml +0 -1
- data/API_COVERAGE.md +19 -0
- data/README.md +29 -12
- data/Rakefile +1 -1
- data/lib/buff/client.rb +26 -0
- data/lib/buff/core.rb +40 -64
- data/lib/buff/datastructure.rb +18 -0
- data/lib/buff/encode.rb +21 -11
- data/lib/buff/error.rb +5 -2
- data/lib/buff/info.rb +10 -0
- data/lib/buff/profile.rb +10 -9
- data/lib/buff/update.rb +33 -35
- data/lib/buff/user.rb +1 -1
- data/lib/buff/version.rb +1 -1
- data/lib/buff.rb +3 -56
- data/spec/fixtures/destroy.txt +10 -0
- data/spec/fixtures/info.txt +10 -0
- data/spec/fixtures/interactions_by_update_id.txt +10 -0
- data/spec/fixtures/link.txt +12 -0
- data/spec/fixtures/profile_authenticated.txt +11 -0
- data/spec/fixtures/profile_schedules_by_id.txt +10 -0
- data/spec/fixtures/profiles_by_id.txt +10 -0
- data/spec/fixtures/update_by_id.txt +10 -0
- data/spec/fixtures/update_by_id_non_auth.txt +9 -0
- data/spec/fixtures/updates_by_profile_id.txt +10 -0
- data/spec/fixtures/updates_by_profile_id_pending.txt +10 -0
- data/spec/fixtures/user_authenticated.txt +19 -0
- data/spec/lib/buff/profile_spec.rb +87 -0
- data/spec/lib/buff/schedule_spec.rb +80 -0
- data/spec/lib/buff/update_spec.rb +107 -12
- data/spec/lib/buff/user_spec.rb +26 -0
- data/spec/lib/buff_spec.rb +0 -228
- data/spec/lib/core_spec.rb +60 -0
- data/spec/spec_helper.rb +82 -0
- metadata +36 -2
@@ -0,0 +1,12 @@
|
|
1
|
+
HTTP/1.1 200 Awesome
|
2
|
+
Content-Type: application/json;charset=UTF-8
|
3
|
+
Date: Wed, 15 May 2013 01:43:34 GMT
|
4
|
+
Server: Apache
|
5
|
+
Vary: Accept-Encoding,User-Agent
|
6
|
+
x-frame-options: SAMEORIGIN
|
7
|
+
Content-Length: 828
|
8
|
+
Connection: keep-alive
|
9
|
+
|
10
|
+
{
|
11
|
+
"shares":47348
|
12
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
HTTP/1.1 200 Awesome
|
2
|
+
Content-Type: application/json;charset=UTF-8
|
3
|
+
Date: Tue, 14 May 2013 05:02:18 GMT
|
4
|
+
Server: Apache
|
5
|
+
Vary: Accept-Encoding,User-Agent
|
6
|
+
X-Cache: Awwww Yea
|
7
|
+
x-frame-options: SAMEORIGIN
|
8
|
+
Content-Length: 845
|
9
|
+
Connection: keep-alive
|
10
|
+
|
11
|
+
[{"_id":"5160746d13f04a5e3a00000f","avatar":"http:\/\/a0.twimg.com\/profile_images\/3604112130.jpeg","avatar_https":"https:\/\/twimg0-a.akamaihd.net\/profile_images\/3604112130.jpeg","counts":{"pending":1,"sent":40},"created_at":1365275757,"default":true,"disconnected":null,"formatted_service":"Twitter","formatted_username":"@example","id":"5160746d13d04a5e3a00000f","quick_signin":true,"schedules":[{"days":["mon","tue","wed","thu","fri","sat","sun"],"times":["06:13","09:10","11:58","12:17","13:49","18:07","21:04","22:13"]}],"service":"twitter","service_id":"737649619","service_type":"profile","service_username":"example","statistics":{"followers":179},"timezone":"America\/New_York","user_id":"5160746d13d04a5e3a00000d","utm_tracking":"enabled","verb":"tweet"}]
|
@@ -0,0 +1,10 @@
|
|
1
|
+
HTTP/1.1 200 Awesome
|
2
|
+
Content-Type: application/json;charset=UTF-8
|
3
|
+
Date: Wed, 15 May 2013 01:53:50 GMT
|
4
|
+
Server: Apache
|
5
|
+
Vary: Accept-Encoding,User-Agent
|
6
|
+
x-frame-options: SAMEORIGIN
|
7
|
+
Content-Length: 128
|
8
|
+
Connection: keep-alive
|
9
|
+
|
10
|
+
[{"days":["mon","tue","wed","thu","fri","sat","sun"],"times":["06:13","09:10","11:58","12:17","13:49","18:07","21:04","22:13"]}]
|
@@ -0,0 +1,10 @@
|
|
1
|
+
HTTP/1.1 200 Awesome
|
2
|
+
Content-Type: application/json;charset=UTF-8
|
3
|
+
Date: Wed, 15 May 2013 01:43:34 GMT
|
4
|
+
Server: Apache
|
5
|
+
Vary: Accept-Encoding,User-Agent
|
6
|
+
x-frame-options: SAMEORIGIN
|
7
|
+
Content-Length: 828
|
8
|
+
Connection: keep-alive
|
9
|
+
|
10
|
+
{"_id":"5160746d13d04a5e3a00000f","avatar":"http:\/\/a0.twimg.com\/profile_images\/3604112130.jpeg","avatar_https":"https:\/\/twimg0-a.akamaihd.net\/profile_images\/3604112130.jpeg","counts":{"pending":1,"sent":46},"created_at":1365275757,"disconnected":null,"formatted_service":"Twitter","formatted_username":"@example","id":"5160746d13d04a5e3a00000f","quick_signin":true,"schedules":[{"days":["mon","tue","wed","thu","fri","sat","sun"],"times":["06:13","09:10","11:58","12:17","13:49","18:07","21:04","22:13"]}],"service":"twitter","service_id":"737649619","service_type":"profile","service_username":"example","statistics":{"followers":179},"timezone":"America\/New_York","user_id":"5160746d13d04a5e3a00000d","utm_tracking":"enabled","verb":"tweet"}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
HTTP/1.1 200 Awesome
|
2
|
+
Content-Type: application/json;charset=UTF-8
|
3
|
+
Date: Wed, 15 May 2013 01:43:34 GMT
|
4
|
+
Server: Apache
|
5
|
+
Vary: Accept-Encoding,User-Agent
|
6
|
+
x-frame-options: SAMEORIGIN
|
7
|
+
Content-Length: 828
|
8
|
+
Connection: keep-alive
|
9
|
+
|
10
|
+
{"id":"4eb8565e0acb04bb82000004","created_at":1320703582,"day":"Monday 7th November","due_at":1320742680,"due_time":"10:09 pm","profile_id":"4eb854340acb04e870000010","profile_service":"twitter","sent_at":1320744001,"service_update_id":"133667319959392256","statistics":{"reach":2460,"clicks":56,"retweets":20,"favorites":1,"mentions":1},"status":"sent","text":"This is just the beginning, the very beginning, of the transfor...","text_formatted":"This is just the beginning, the very beginning, of th...","user_id":"4eb9276e0acb04bb81000067","via":"chrome"}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
HTTP/1.1 401 Authorization Required
|
2
|
+
Content-Type: text/html; charset=UTF-8
|
3
|
+
Date: Fri, 17 May 2013 02:46:37 GMT
|
4
|
+
Server: Apache
|
5
|
+
Vary: Accept-Encoding,User-Agent
|
6
|
+
WWW-Authenticate: OAuth realm='Service', error='invalid_request', error_description='The request is missing a required parameter, includes an unsupported parameter or parameter value, repeats the same parameter, uses more than one method for including an access token, or is otherwise malformed.'
|
7
|
+
Content-Length: 0
|
8
|
+
Connection: keep-alive
|
9
|
+
|
@@ -0,0 +1,10 @@
|
|
1
|
+
HTTP/1.1 200 Awesome
|
2
|
+
Content-Type: application/json;charset=UTF-8
|
3
|
+
Date: Wed, 15 May 2013 01:43:34 GMT
|
4
|
+
Server: Apache
|
5
|
+
Vary: Accept-Encoding,User-Agent
|
6
|
+
x-frame-options: SAMEORIGIN
|
7
|
+
Content-Length: 828
|
8
|
+
Connection: keep-alive
|
9
|
+
|
10
|
+
{"total":8,"updates":[{"id":"4ec93ae4512f7e6307000002","created_at":1320703582,"day":"Monday 7th November","due_at":1320543480,"due_time":"07:01 pm","profile_id":"4eb854340acb04e870000010","profile_service":"twitter","status":"buffer","text":"This is me in an alternate life where i can breakdance j.mp/w...","text_formatted":"This is me in an alternate life where i can breakda...","user_id":"4eb9276e0acb04bb81000067","via":"firefox"},] }
|
@@ -0,0 +1,10 @@
|
|
1
|
+
HTTP/1.1 200 Awesome
|
2
|
+
Content-Type: application/json;charset=UTF-8
|
3
|
+
Date: Thu, 16 May 2013 04:48:14 GMT
|
4
|
+
Server: Apache
|
5
|
+
Vary: Accept-Encoding,User-Agent
|
6
|
+
x-frame-options: SAMEORIGIN
|
7
|
+
Content-Length: 737
|
8
|
+
Connection: keep-alive
|
9
|
+
|
10
|
+
{"total":1,"updates":[{"_id":"519464f2872cad3734000028","created_at":1368679666,"day":"Today","due_at":1368699180,"due_time":"6:13 am","id":"519464f2872cad3734000028","profile_id":"5160746d13d04a5e3a00000f","profile_service":"twitter","shared_now":false,"status":"buffer","text":"Exciting to have even 1 person fork my fork of a repo :) jaysonlane\/buffer-ruby \u00b7 GitHub http:\/\/bit.ly\/15OS4ap","text_formatted":"Exciting to have even 1 person fork my fork of a repo :) jaysonlane\/buffer-ruby \u00b7 GitHub <a class=\"url\" href=\"http:\/\/bit.ly\/15OS4ap\" rel=\"external nofollow\" target=\"_blank\">http:\/\/bit.ly\/15OS4ap<\/a>","type":"link","updated_at":1368679666,"user_id":"5160746d54f04a5e3a00000d","via":"bookmarklet"}]}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Server: nginx/0.7.65
|
3
|
+
Date: Thu, 03 Mar 2011 19:25:34 GMT
|
4
|
+
Content-Type: application/json
|
5
|
+
Connection: keep-alive
|
6
|
+
Keep-Alive: timeout=20
|
7
|
+
Content-Length: 380
|
8
|
+
|
9
|
+
{
|
10
|
+
"_id":"4f0c0a06512f7ef214000000",
|
11
|
+
"activity_at":1343654640,
|
12
|
+
"created_at":1326189062,
|
13
|
+
"id":"4f0c0a06512f7ef214000000",
|
14
|
+
"plan":"free",
|
15
|
+
"referral_link":"http:\/\/bufferapp.com\/r\/abcde",
|
16
|
+
"referral_token":"abcde",
|
17
|
+
"secret_email":"supersecret@to.bufferapp.com",
|
18
|
+
"timezone":"Asia\/Tel_Aviv"
|
19
|
+
}
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Buff::Client::Profile do
|
4
|
+
let(:id) { "5160746d54f04a5e3a00000f" }
|
5
|
+
|
6
|
+
subject do
|
7
|
+
Buff::Client.new("some_token")
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#profiles" do
|
11
|
+
let(:rash) { Buff::Client.new("some_token").profiles }
|
12
|
+
|
13
|
+
before(:each) do
|
14
|
+
url = "#{ base_path }/profiles.json"
|
15
|
+
stub_with_to_return(:get, url, 'profile_authenticated.txt')
|
16
|
+
end
|
17
|
+
|
18
|
+
it "makes the correct url request" do
|
19
|
+
subject.profiles
|
20
|
+
end
|
21
|
+
|
22
|
+
it "returns a Rash collection object" do
|
23
|
+
rash[0].class.should eq(Buff::Profile)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "provides an accessor for plan" do
|
27
|
+
rash[0].service.should eq("twitter")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "#profile_by_id" do
|
32
|
+
let(:id) { "5160746d54f04a5e3a00000f" }
|
33
|
+
before(:each) do
|
34
|
+
url = "#{base_path}/profiles/#{id}.json"
|
35
|
+
fixture_name = "profiles_by_id.txt"
|
36
|
+
stub_with_to_return(:get, url, fixture_name)
|
37
|
+
end
|
38
|
+
|
39
|
+
let(:rash) { Buff::Client.new("some_token").profile_by_id(id) }
|
40
|
+
|
41
|
+
it "returns a rash collection" do
|
42
|
+
rash.class.should eq(Buff::Profile)
|
43
|
+
end
|
44
|
+
|
45
|
+
it "accesses formatted service" do
|
46
|
+
rash.formatted_service.should eq("Twitter")
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "#schedules_by_profile_id" do
|
51
|
+
before(:each) do
|
52
|
+
url = "#{base_path}/profiles/#{id}/schedules.json"
|
53
|
+
fixture_name = 'profile_schedules_by_id.txt'
|
54
|
+
stub_with_to_return(:get, url, fixture_name)
|
55
|
+
end
|
56
|
+
|
57
|
+
let(:rash) { Buff::Client.new("some_token").schedules_by_profile_id(id) }
|
58
|
+
|
59
|
+
it "returns a rash collection" do
|
60
|
+
rash[0].class.should eq(Buff::Schedule)
|
61
|
+
end
|
62
|
+
|
63
|
+
it "accesses days" do
|
64
|
+
expect(rash[0].days).to include("mon")
|
65
|
+
end
|
66
|
+
|
67
|
+
it "accesses times" do
|
68
|
+
expect(rash[0].times).to include("06:13")
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
describe "#info" do
|
74
|
+
before do
|
75
|
+
stub_request(:get, "#{base_path}/info/configuration.json?access_token=some_token").
|
76
|
+
to_return(fixture("info.txt"))
|
77
|
+
end
|
78
|
+
|
79
|
+
it "connects to the correct endpoint" do
|
80
|
+
subject.info
|
81
|
+
end
|
82
|
+
|
83
|
+
it "retrieves the correct name" do
|
84
|
+
subject.info.services.twitter.types.profile.name.should eq("Twitter")
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Buff::Schedules do
|
4
|
+
before do
|
5
|
+
@schedule = JSON.parse <<EOF
|
6
|
+
{
|
7
|
+
"days" : [
|
8
|
+
"mon",
|
9
|
+
"tue",
|
10
|
+
"wed",
|
11
|
+
"thu",
|
12
|
+
"fri"
|
13
|
+
],
|
14
|
+
"times" : [
|
15
|
+
"12:00",
|
16
|
+
"17:00",
|
17
|
+
"18:00"
|
18
|
+
]
|
19
|
+
}
|
20
|
+
EOF
|
21
|
+
|
22
|
+
@sample_schedules = JSON.parse <<EOF
|
23
|
+
{ "schedules" : [{
|
24
|
+
"days" : [
|
25
|
+
"mon",
|
26
|
+
"tue",
|
27
|
+
"wed",
|
28
|
+
"thu",
|
29
|
+
"fri"
|
30
|
+
],
|
31
|
+
"times" : [
|
32
|
+
"12:00",
|
33
|
+
"17:00",
|
34
|
+
"18:00"
|
35
|
+
]
|
36
|
+
},
|
37
|
+
{
|
38
|
+
"days" : [
|
39
|
+
"mon",
|
40
|
+
"tue",
|
41
|
+
"wed",
|
42
|
+
"thu",
|
43
|
+
"fri"
|
44
|
+
],
|
45
|
+
"times" : [
|
46
|
+
"12:00",
|
47
|
+
"17:00",
|
48
|
+
"18:00"
|
49
|
+
]
|
50
|
+
}]
|
51
|
+
}
|
52
|
+
EOF
|
53
|
+
end
|
54
|
+
|
55
|
+
it "accepts an array of days" do
|
56
|
+
lambda {
|
57
|
+
schedules = Buff::Schedules.new
|
58
|
+
schedules << Buff::Schedule.new
|
59
|
+
}.should_not raise_error
|
60
|
+
end
|
61
|
+
|
62
|
+
it "dumping a double schedule yields correct json" do
|
63
|
+
schedules = Buff::Schedules.new
|
64
|
+
schedules << @schedule << @schedule
|
65
|
+
@sample_schedules = @sample_schedules.to_json
|
66
|
+
|
67
|
+
schedules.dump.should eq(@sample_schedules)
|
68
|
+
end
|
69
|
+
|
70
|
+
describe "#set_schedules" do
|
71
|
+
let(:id) { "5160746d54f04a5e3a00000f" }
|
72
|
+
it "throw error if schedules is empty" do
|
73
|
+
lambda {
|
74
|
+
Buff::Client.new("some_token").set_schedules(id) }.
|
75
|
+
should raise_error(ArgumentError)
|
76
|
+
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
@@ -60,15 +60,59 @@ describe Buff::Client do
|
|
60
60
|
end
|
61
61
|
|
62
62
|
describe "#interactions_by_update_id" do
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
url = "https://api.bufferapp.com/1/updates/4ecda476542f7ee521000006/interactions.json?access_token=some_token&page=2"
|
68
|
-
id = "4ecda476542f7ee521000006"
|
63
|
+
let(:url) { "https://api.bufferapp.com/1/updates/4ecda476542f7ee521000006/interactions.json?access_token=some_token&page=2" }
|
64
|
+
let(:id) { "4ecda476542f7ee521000006" }
|
65
|
+
|
66
|
+
before do
|
69
67
|
stub_request(:get, url).
|
70
68
|
to_return(fixture("interactions_by_update_id.txt"))
|
71
|
-
|
69
|
+
end
|
70
|
+
|
71
|
+
it "requires an id" do
|
72
|
+
lambda { client.interactions_by_update_id(page: 2) }.
|
73
|
+
should raise_error(Buff::InvalidIdLength)
|
74
|
+
end
|
75
|
+
|
76
|
+
it "allows optional params" do
|
77
|
+
response =<<EOF
|
78
|
+
{
|
79
|
+
"total":2,
|
80
|
+
"interactions":[
|
81
|
+
{
|
82
|
+
"_id":"50f98310c5ac415d7f2e74fd",
|
83
|
+
"created_at":1358509258,
|
84
|
+
"event":"favorite",
|
85
|
+
"id":"50f98310c5ac415d7f2e74fd",
|
86
|
+
"interaction_id":"292235127847788544",
|
87
|
+
"user":{
|
88
|
+
"username":"Crispy Potatoes",
|
89
|
+
"followers":160,
|
90
|
+
"avatar":"http:\/\/si0.twimg.com\/profile_images\/...",
|
91
|
+
"avatar_https":"https:\/\/si0.twimg.com\/profile_images\/...",
|
92
|
+
"twitter_id":"70712344376"
|
93
|
+
}
|
94
|
+
},
|
95
|
+
{
|
96
|
+
"_id":"50f8623ac5ac415d7f1d4f77",
|
97
|
+
"created_at":1358454592,
|
98
|
+
"event":"retweet",
|
99
|
+
"id":"50f8623ac5ac415d7f1d4f77",
|
100
|
+
"interaction_id":"292005842654461953",
|
101
|
+
"user":{
|
102
|
+
"username":"Lucky Number 8",
|
103
|
+
"followers":36079,
|
104
|
+
"avatar":"http:\/\/si0.twimg.com\/profile_images\/2901468678\/...",
|
105
|
+
"avatar_https":"https:\/\/si0.twimg.com\/profile_images\/2901468678\/...",
|
106
|
+
"twitter_id":"1423444249"
|
107
|
+
}
|
108
|
+
}
|
109
|
+
]
|
110
|
+
}
|
111
|
+
EOF
|
112
|
+
stub_request(:get, "https://api.bufferapp.com/1/updates/4ecda476542f7ee521000006/interactions.json?access_token=some_token&count=3&event=favorite&page=2").
|
113
|
+
with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Faraday v0.8.7'}).
|
114
|
+
to_return(:status => 200, :body => response, :headers => {})
|
115
|
+
client.interactions_by_update_id(id, page: 2, count: 3, event: "favorite")
|
72
116
|
end
|
73
117
|
end
|
74
118
|
|
@@ -97,9 +141,8 @@ describe Buff::Client do
|
|
97
141
|
stub_request(:post, %r{https://api\.bufferapp\.com/1/profiles/4ecda256512f7ee521000001/updates/reorder\.json\?access_token=.*}).
|
98
142
|
with(:body => {"order"=>["4ecda256512f7ee521000001", "4ecda256512f7ee521000001", "4ecda256512f7ee521000001"]},
|
99
143
|
:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type'=>'application/x-www-form-urlencoded', 'User-Agent'=>'Faraday v0.8.7'}).
|
100
|
-
to_return(:status => 200, :body =>
|
144
|
+
to_return(:status => 200, :body => reorder_updates_body_response, :headers => {})
|
101
145
|
client.reorder_updates(id_no, order_hash)
|
102
|
-
|
103
146
|
end
|
104
147
|
end
|
105
148
|
|
@@ -107,19 +150,71 @@ describe Buff::Client do
|
|
107
150
|
it "connects to appropriate endpoint" do
|
108
151
|
id_no = "4ecda256512f7ee521000001"
|
109
152
|
stub_request(:post, %r{https://api\.bufferapp\.com/1/profiles/4ecda256512f7ee521000001/updates/shuffle\.json\?access_token=.*}).
|
110
|
-
|
111
|
-
|
153
|
+
with(:body => {"count"=>"10"}).
|
154
|
+
to_return(:status => 200, :body => '{"success": true,
|
155
|
+
"updates": [],
|
156
|
+
"time_to_shuffle":0.0041220188140869}')
|
157
|
+
client.shuffle_updates(id_no, count: 10)
|
112
158
|
end
|
113
159
|
end
|
160
|
+
|
114
161
|
describe "#share_update" do
|
115
162
|
it "should connect to correct endpoint" do
|
116
163
|
stub_request(:post, %r{https://api\.bufferapp\.com/1/updates/4ecda256512f7ee521000001/share\.json\?access_token=.*}).
|
117
|
-
to_return(:status => 200, :body => "
|
164
|
+
to_return(:status => 200, :body => '{"success": true}', :headers => {})
|
118
165
|
update_id = "4ecda256512f7ee521000001"
|
119
166
|
client.share_update(update_id)
|
120
167
|
end
|
121
168
|
end
|
122
169
|
|
170
|
+
describe "#create_update" do
|
171
|
+
|
172
|
+
let(:body_content) do {text: "Text for an update",
|
173
|
+
profile_ids: [
|
174
|
+
"4eb854340acb04e870000010",
|
175
|
+
"4eb9276e0acb04bb81000067"
|
176
|
+
]}
|
177
|
+
end
|
178
|
+
|
179
|
+
let(:url) { %r{https://api\.bufferapp\.com/1/updates/create\.json\?access_token=.*} }
|
180
|
+
|
181
|
+
context "should create an update" do
|
182
|
+
it "when only required params are present" do
|
183
|
+
stub_request(:post, url).
|
184
|
+
with(:body => body_content).
|
185
|
+
to_return(:status => 200, :body => create_update_return_body, :headers => {})
|
186
|
+
client.create_update(body: body_content)
|
187
|
+
end
|
188
|
+
it "when optional params are included" do
|
189
|
+
body_content[:media] = {}
|
190
|
+
body_content[:media][:link] = "http://google.com"
|
191
|
+
body_content[:media][:description] = "Google Homepage"
|
192
|
+
stub_request(:post, url).
|
193
|
+
with(:body => body_content).
|
194
|
+
to_return(:status => 200, :body => create_update_return_body, :headers => {})
|
195
|
+
client.create_update(body: body_content)
|
196
|
+
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
describe "#modify_update_text" do
|
202
|
+
|
203
|
+
let(:body_content) { {text: "Text for an updated text for update"} }
|
204
|
+
|
205
|
+
id = "4ecda256512f7ee521000004"
|
206
|
+
let(:url) { %r{https://api\.bufferapp\.com/1/updates/#{ id }/update\.json\?access_token=.*} }
|
207
|
+
|
208
|
+
context "should modify an update" do
|
209
|
+
it "when params are present" do
|
210
|
+
stub_request(:post, url).
|
211
|
+
with(:body => body_content).
|
212
|
+
to_return(:status => 200, :body => modify_update_response, :headers => {})
|
213
|
+
client.modify_update_text(id, body: body_content)
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
123
218
|
describe "#destroy_update" do
|
124
219
|
it "connects to correct endpoint" do
|
125
220
|
stub_request(:post, %r{https://api\.bufferapp\.com/1/updates/4ecda256512f7ee521000001/destroy\.json\?access_token=.*}).
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Buff::Client::User do
|
4
|
+
let(:id) { "5160746d54f04a5e3a00000f" }
|
5
|
+
|
6
|
+
subject do
|
7
|
+
Buff::Client.new("some_token")
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#user_info" do
|
11
|
+
let(:rash) { subject.user_info }
|
12
|
+
|
13
|
+
before(:each) do
|
14
|
+
url = "#{ base_path }/user.json"
|
15
|
+
stub_with_to_return(:get, url, "user_authenticated.txt")
|
16
|
+
end
|
17
|
+
|
18
|
+
it "returns a Rash object" do
|
19
|
+
rash.class.should eq(Buff::UserInfo)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "provides an accessor for plan" do
|
23
|
+
rash.plan.should eq("free")
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|