gratitude 0.0.9 → 0.0.10
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.
- checksums.yaml +4 -4
- data/.travis.yml +4 -1
- data/CHANGELOG.md +7 -0
- data/Gemfile +1 -1
- data/LICENSE.txt +1 -1
- data/README.md +119 -19
- data/Rakefile +9 -1
- data/lib/gratitude/tips.rb +36 -26
- data/lib/gratitude/version.rb +1 -1
- data/spec/cassettes/get_tips.json +63 -1
- data/spec/cassettes/post_multiple_tips.json +68 -1
- data/spec/cassettes/post_single_tip.json +68 -1
- data/spec/cassettes/post_tip_error.json +68 -1
- data/spec/cassettes/statistics.json +113 -1
- data/spec/cassettes/update_and_prune.json +193 -0
- data/spec/gratitude/client_spec.rb +15 -13
- data/spec/gratitude/payday_spec.rb +46 -56
- data/spec/gratitude/profile_spec.rb +57 -78
- data/spec/gratitude/statistics_spec.rb +63 -70
- data/spec/gratitude/tips_spec.rb +67 -159
- data/spec/gratitude/version_spec.rb +2 -2
- data/spec/spec_helper.rb +1 -1
- metadata +18 -16
@@ -3,282 +3,275 @@ require "spec_helper"
|
|
3
3
|
describe Gratitude::Statistics do
|
4
4
|
|
5
5
|
describe "default attributes" do
|
6
|
-
it "
|
7
|
-
Gratitude::Statistics.
|
6
|
+
it "includes httparty methods" do
|
7
|
+
expect(Gratitude::Statistics).to include(HTTParty)
|
8
8
|
end
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
it "sets the base uri equal to gittip's payday api endpoint" do
|
11
|
+
expect(Gratitude::Statistics.base_uri)
|
12
|
+
.to eq("https://www.gittip.com/about/stats.json")
|
13
13
|
end
|
14
|
-
end
|
14
|
+
end
|
15
15
|
|
16
16
|
describe "instance methods" do
|
17
|
-
|
18
|
-
|
19
|
-
VCR.insert_cassette "statistics"
|
20
|
-
end
|
21
|
-
|
22
|
-
after do
|
23
|
-
VCR.eject_cassette
|
24
|
-
end
|
25
|
-
|
17
|
+
before { VCR.insert_cassette "statistics" }
|
18
|
+
after { VCR.eject_cassette }
|
26
19
|
let(:stats) { Gratitude::Statistics.current }
|
27
20
|
|
28
|
-
it "
|
21
|
+
it "responds to #repsonse" do
|
29
22
|
expect(stats).to respond_to(:response)
|
30
23
|
end
|
31
24
|
|
32
25
|
describe "#average_tip_amount" do
|
33
|
-
it "
|
26
|
+
it "returns the correct average tip amount" do
|
34
27
|
expect(stats.average_tip_amount).to eq(1.2348237280979524)
|
35
28
|
end
|
36
29
|
|
37
|
-
it "
|
30
|
+
it "returns a float" do
|
38
31
|
expect(stats.average_tip_amount.class).to be(Float)
|
39
32
|
end
|
40
33
|
|
41
|
-
it "
|
34
|
+
it "returns the same value as its alias: #average_tip" do
|
42
35
|
expect(stats.average_tip_amount).to eq(stats.average_tip)
|
43
36
|
end
|
44
37
|
end
|
45
38
|
|
46
39
|
describe "#average_number_of_tippees" do
|
47
|
-
it "
|
40
|
+
it "returns the correct average number of tippees" do
|
48
41
|
expect(stats.average_number_of_tippees).to eq(3)
|
49
42
|
end
|
50
43
|
|
51
|
-
it "
|
44
|
+
it "returns a fixnum" do
|
52
45
|
expect(stats.average_number_of_tippees.class).to be(Fixnum)
|
53
46
|
end
|
54
47
|
|
55
|
-
it "
|
48
|
+
it "returns the same value as its alias: #average_tippees" do
|
56
49
|
expect(stats.average_number_of_tippees).to eq(stats.average_tippees)
|
57
50
|
end
|
58
51
|
end
|
59
52
|
|
60
53
|
describe "#amount_in_escrow" do
|
61
|
-
it "
|
54
|
+
it "returns the correct amount in escrow" do
|
62
55
|
expect(stats.amount_in_escrow).to eq(50441.17)
|
63
56
|
end
|
64
57
|
|
65
|
-
it "
|
58
|
+
it "returns a float" do
|
66
59
|
expect(stats.amount_in_escrow.class).to be(Float)
|
67
60
|
end
|
68
61
|
|
69
|
-
it "
|
62
|
+
it "returns the same value as its alias: #escrow" do
|
70
63
|
expect(stats.amount_in_escrow).to eq(stats.escrow)
|
71
64
|
end
|
72
65
|
end
|
73
66
|
|
74
67
|
describe "#last_thursday" do
|
75
|
-
it "
|
68
|
+
it "returns the correct value for last thursday" do
|
76
69
|
expect(stats.last_thursday).to eq("last Thursday")
|
77
70
|
end
|
78
71
|
|
79
|
-
it "
|
72
|
+
it "returns a string" do
|
80
73
|
expect(stats.last_thursday.class).to be(String)
|
81
74
|
end
|
82
75
|
end
|
83
76
|
|
84
77
|
describe "#number_of_achs" do
|
85
|
-
it "
|
78
|
+
it "returns the correct number of ach credits" do
|
86
79
|
expect(stats.number_of_ach_credits).to eq(299)
|
87
80
|
end
|
88
81
|
|
89
|
-
it "
|
82
|
+
it "returns a fixnum" do
|
90
83
|
expect(stats.number_of_ach_credits.class).to be(Fixnum)
|
91
84
|
end
|
92
85
|
|
93
|
-
it "
|
86
|
+
it "returns the same value as its alias: #nach" do
|
94
87
|
expect(stats.number_of_ach_credits).to eq(stats.nach)
|
95
88
|
end
|
96
89
|
|
97
|
-
it "
|
90
|
+
it "returns the same value as its alias: #number_of_achs" do
|
98
91
|
expect(stats.number_of_ach_credits).to eq(stats.number_of_achs)
|
99
92
|
end
|
100
93
|
end
|
101
94
|
|
102
95
|
describe "#number_of_active_users" do
|
103
|
-
it "
|
96
|
+
it "returns the correct number of active users" do
|
104
97
|
expect(stats.number_of_active_users).to eq(1719)
|
105
98
|
end
|
106
99
|
|
107
|
-
it "
|
100
|
+
it "returns a fixnum" do
|
108
101
|
expect(stats.number_of_active_users.class).to be(Fixnum)
|
109
102
|
end
|
110
103
|
|
111
|
-
it "
|
104
|
+
it "returns the same value as its alias: #nactive" do
|
112
105
|
expect(stats.number_of_active_users).to eq(stats.nactive)
|
113
106
|
end
|
114
107
|
end
|
115
108
|
|
116
109
|
describe "#number_of_credit_cards" do
|
117
|
-
it "
|
110
|
+
it "returns the correct number of credit cards on file" do
|
118
111
|
expect(stats.number_of_credit_cards).to eq(1496)
|
119
112
|
end
|
120
113
|
|
121
|
-
it "
|
114
|
+
it "returns a fixnum" do
|
122
115
|
expect(stats.number_of_credit_cards.class).to be(Fixnum)
|
123
116
|
end
|
124
117
|
|
125
|
-
it "
|
118
|
+
it "returns the same value as its alias: #ncc" do
|
126
119
|
expect(stats.number_of_credit_cards).to eq(stats.ncc)
|
127
120
|
end
|
128
121
|
end
|
129
122
|
|
130
123
|
describe "#number_of_givers" do
|
131
|
-
it "
|
124
|
+
it "returns the correct number of givers" do
|
132
125
|
expect(stats.number_of_givers).to eq(1113)
|
133
126
|
end
|
134
127
|
|
135
|
-
it "
|
128
|
+
it "returns a fixnum" do
|
136
129
|
expect(stats.number_of_givers.class).to be(Fixnum)
|
137
130
|
end
|
138
131
|
|
139
|
-
it "
|
132
|
+
it "returns the same value as its alias: #ngivers" do
|
140
133
|
expect(stats.number_of_givers).to eq(stats.ngivers)
|
141
134
|
end
|
142
135
|
end
|
143
136
|
|
144
137
|
describe "#number_who_give_and_receive" do
|
145
|
-
it "
|
138
|
+
it "returns the correct number of users who both give and receive" do
|
146
139
|
expect(stats.number_who_give_and_receive).to eq(301)
|
147
140
|
end
|
148
141
|
|
149
|
-
it "
|
142
|
+
it "returns a fixnum" do
|
150
143
|
expect(stats.number_who_give_and_receive.class).to be(Fixnum)
|
151
144
|
end
|
152
145
|
|
153
|
-
it "
|
146
|
+
it "returns the same value as its alias: #noverlap" do
|
154
147
|
expect(stats.number_who_give_and_receive).to eq(stats.noverlap)
|
155
148
|
end
|
156
149
|
end
|
157
150
|
|
158
151
|
describe "#number_of_receivers" do
|
159
|
-
it "
|
152
|
+
it "returns the correct number of receivers" do
|
160
153
|
expect(stats.number_of_receivers).to eq(907)
|
161
154
|
end
|
162
155
|
|
163
|
-
it "
|
156
|
+
it "returns a fixnum" do
|
164
157
|
expect(stats.number_of_receivers.class).to be(Fixnum)
|
165
158
|
end
|
166
159
|
|
167
|
-
it "
|
160
|
+
it "returns the same value as its alias: #nreceivers" do
|
168
161
|
expect(stats.number_of_receivers).to eq(stats.nreceivers)
|
169
162
|
end
|
170
163
|
end
|
171
164
|
|
172
165
|
describe "#other_people" do
|
173
|
-
it "
|
166
|
+
it "returns the correct value for #other_people" do
|
174
167
|
expect(stats.other_people).to eq("three other people")
|
175
168
|
end
|
176
169
|
|
177
|
-
it "
|
170
|
+
it "returns a string" do
|
178
171
|
expect(stats.other_people.class).to be(String)
|
179
172
|
end
|
180
173
|
end
|
181
174
|
|
182
175
|
describe "#percentage_of_users_with_credit_cards" do
|
183
|
-
it "
|
176
|
+
it "returns the correct value for #percentage_of_users_with_credit_cards" do
|
184
177
|
expect(stats.percentage_of_users_with_credit_cards).to eq("7.6")
|
185
178
|
end
|
186
179
|
|
187
|
-
it "
|
180
|
+
it "returns a string" do
|
188
181
|
expect(stats.percentage_of_users_with_credit_cards.class).to be(String)
|
189
182
|
end
|
190
183
|
|
191
|
-
it "
|
184
|
+
it "returns the same value as its alias: #pcc" do
|
192
185
|
expect(stats.percentage_of_users_with_credit_cards).to eq(stats.pcc)
|
193
186
|
end
|
194
187
|
end
|
195
188
|
|
196
189
|
describe "#punctuation" do
|
197
|
-
it "
|
190
|
+
it "returns the correct value for #punctuation" do
|
198
191
|
expect(stats.punctuation).to eq(".")
|
199
192
|
end
|
200
193
|
|
201
|
-
it "
|
194
|
+
it "returns a string" do
|
202
195
|
expect(stats.punctuation.class).to be(String)
|
203
196
|
end
|
204
197
|
|
205
|
-
it "
|
198
|
+
it "returns the same value as its alias: #pcc" do
|
206
199
|
expect(stats.punctuation).to eq(stats.punc)
|
207
200
|
end
|
208
201
|
end
|
209
202
|
|
210
203
|
describe "#statements" do
|
211
|
-
it "
|
204
|
+
it "returns an array" do
|
212
205
|
expect(stats.statements.class).to be(Array)
|
213
206
|
end
|
214
207
|
|
215
|
-
it "
|
208
|
+
it "contain the currect number of elements in the array" do
|
216
209
|
expect(stats.statements.size).to eq(16)
|
217
210
|
end
|
218
211
|
|
219
|
-
it "
|
212
|
+
it "has a hash for each element in the array" do
|
220
213
|
expect(stats.statements.first.class).to be(Hash)
|
221
214
|
end
|
222
215
|
|
223
|
-
it "
|
216
|
+
it "has statement as a key in each hash element" do
|
224
217
|
expect(stats.statements.first.has_key?("statement")).to be(true)
|
225
218
|
end
|
226
219
|
|
227
|
-
it "
|
220
|
+
it "has username as a key in each hash element" do
|
228
221
|
expect(stats.statements.first.has_key?("username")).to be(true)
|
229
222
|
end
|
230
223
|
end
|
231
224
|
|
232
225
|
describe "#this_thursday" do
|
233
|
-
it "
|
226
|
+
it "returns the correct value for this thursday" do
|
234
227
|
expect(stats.this_thursday).to eq("this Thursday")
|
235
228
|
end
|
236
229
|
|
237
|
-
it "
|
230
|
+
it "returns a string" do
|
238
231
|
expect(stats.this_thursday.class).to be(String)
|
239
232
|
end
|
240
233
|
end
|
241
234
|
|
242
235
|
describe "#tip_distribution_json" do
|
243
|
-
it "
|
236
|
+
it "returns a hash" do
|
244
237
|
expect(stats.tip_distribution_json.class).to be(Hash)
|
245
238
|
end
|
246
239
|
end
|
247
240
|
|
248
241
|
describe "#number_of_tips" do
|
249
|
-
it "
|
242
|
+
it "returns the correct number of tips" do
|
250
243
|
expect(stats.number_of_tips).to eq(4710)
|
251
244
|
end
|
252
245
|
|
253
|
-
it "
|
246
|
+
it "returns a fixnum" do
|
254
247
|
expect(stats.number_of_tips.class).to be(Fixnum)
|
255
248
|
end
|
256
249
|
|
257
|
-
it "
|
250
|
+
it "returns the same value as its alias: #tip_n" do
|
258
251
|
expect(stats.number_of_tips).to eq(stats.tip_n)
|
259
252
|
end
|
260
253
|
end
|
261
254
|
|
262
255
|
describe "#value_of_total_backed_tips" do
|
263
|
-
it "
|
256
|
+
it "returns the correct value of total backed tips" do
|
264
257
|
expect(stats.value_of_total_backed_tips).to eq(5849.36)
|
265
258
|
end
|
266
259
|
|
267
|
-
it "
|
260
|
+
it "returns a float" do
|
268
261
|
expect(stats.value_of_total_backed_tips.class).to be(Float)
|
269
262
|
end
|
270
263
|
|
271
|
-
it "
|
264
|
+
it "returns the same value as its alias: #total_backed_tips" do
|
272
265
|
expect(stats.value_of_total_backed_tips).to eq(stats.total_backed_tips)
|
273
266
|
end
|
274
267
|
end
|
275
268
|
|
276
269
|
describe "#transfer_volume" do
|
277
|
-
it "
|
270
|
+
it "returns the correct transfer volume" do
|
278
271
|
expect(stats.transfer_volume).to eq(5464.38)
|
279
272
|
end
|
280
273
|
|
281
|
-
it "
|
274
|
+
it "returns a float" do
|
282
275
|
expect(stats.transfer_volume.class).to be(Float)
|
283
276
|
end
|
284
277
|
end
|
data/spec/gratitude/tips_spec.rb
CHANGED
@@ -1,187 +1,95 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Gratitude::Client::Tips do
|
4
|
-
|
5
4
|
let(:username) { "gratitude_test" }
|
6
5
|
let(:api_key) { "5962b93a-5bf7-4cb6-ae6f-aa4114c5e4f2" }
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
6
|
+
let(:client) do
|
7
|
+
Gratitude::Client.new(:username => username, :api_key => api_key)
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "GET Requests" do
|
11
|
+
before { VCR.insert_cassette "get_tips" }
|
12
|
+
after { VCR.eject_cassette }
|
13
|
+
let(:current_tips) do
|
14
|
+
[
|
15
|
+
{"amount"=>"1.00", "platform"=>"gittip", "username"=>"whit537"},
|
16
|
+
{"amount"=>"0.25", "platform"=>"gittip", "username"=>"JohnKellyFerguson"}
|
17
|
+
]
|
16
18
|
end
|
17
19
|
|
18
|
-
describe "#
|
19
|
-
it "returns the correct
|
20
|
-
expect(client.
|
20
|
+
describe "#current_tips" do
|
21
|
+
it "returns the correct array of current tips" do
|
22
|
+
expect(client.current_tips).to eq (current_tips)
|
21
23
|
end
|
22
24
|
end
|
23
25
|
|
24
|
-
describe "#
|
25
|
-
it "returns the correct
|
26
|
-
expect(client.
|
27
|
-
{ "amount" => "1", "platform" => "gittip", "username" => "whit537" })
|
28
|
-
end
|
29
|
-
|
30
|
-
it "returns the correct tip hash when given an integer in a string" do
|
31
|
-
expect(client.tip_hash_based_upon("whit537", "1")).to eq(
|
32
|
-
{ "amount" => "1", "platform" => "gittip", "username" => "whit537" })
|
33
|
-
end
|
34
|
-
|
35
|
-
it "returns the correct tip hash when given a float" do
|
36
|
-
expect(client.tip_hash_based_upon("whit537", 0.25)).to eq(
|
37
|
-
{ "amount" => "0.25", "platform" => "gittip", "username" => "whit537" })
|
38
|
-
end
|
39
|
-
|
40
|
-
it "returns the correct tip hash when given a float" do
|
41
|
-
expect(client.tip_hash_based_upon("whit537", "0.25")).to eq(
|
42
|
-
{ "amount" => "0.25", "platform" => "gittip", "username" => "whit537" })
|
26
|
+
describe "#current_tips_total" do
|
27
|
+
it "returns the correct total of current tips" do
|
28
|
+
expect(client.current_tips_total).to eq(1.25)
|
43
29
|
end
|
44
|
-
end
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
context "when
|
50
|
-
|
51
|
-
|
52
|
-
|
30
|
+
end
|
31
|
+
end #GET Requests
|
32
|
+
|
33
|
+
describe "POST Requests" do
|
34
|
+
describe "#update_tips" do
|
35
|
+
context "when updating a single tip" do
|
36
|
+
before { VCR.insert_cassette "post_single_tip" }
|
37
|
+
after { VCR.eject_cassette }
|
38
|
+
let(:single_tip_response) do
|
39
|
+
[{"amount"=>"5", "platform"=>"gittip", "username"=>"whit537"}]
|
53
40
|
end
|
54
41
|
|
55
|
-
it "
|
56
|
-
expect(
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
{ "amount" => "1", "platform" => "gittip", "username" => "whit537" },
|
61
|
-
{ "amount" => "0.25", "platform" => "gittip", "username" => "JohnKellyFerguson" }
|
62
|
-
])
|
42
|
+
it "updates the correct tip information" do
|
43
|
+
expect(
|
44
|
+
client.update_tips(
|
45
|
+
[{ :username => "whit537", :amount => "5" }]
|
46
|
+
).parsed_response).to eq(single_tip_response)
|
63
47
|
end
|
64
|
-
end #
|
48
|
+
end #update_tips
|
65
49
|
|
66
|
-
context "when
|
67
|
-
|
68
|
-
|
69
|
-
[{ "amount" => "1", "platform" => "gittip", "username" => "whit537" }])
|
70
|
-
end
|
50
|
+
context "when updating multiple tips" do
|
51
|
+
before { VCR.insert_cassette "post_multiple_tips" }
|
52
|
+
after { VCR.eject_cassette }
|
71
53
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
{ "amount" => "1", "platform" => "gittip", "username" => "whit537" },
|
78
|
-
{ "amount" => "0.25", "platform" => "gittip", "username" => "JohnKellyFerguson" }
|
79
|
-
])
|
54
|
+
let(:multi_tip_response) do
|
55
|
+
[
|
56
|
+
{"amount"=>"10", "platform"=>"gittip", "username"=>"whit537"},
|
57
|
+
{"amount"=>"4", "platform"=>"gittip", "username"=>"JohnKellyFerguson"}
|
58
|
+
]
|
80
59
|
end
|
81
|
-
end # strings as keys
|
82
|
-
|
83
|
-
end #tips_array
|
84
|
-
|
85
|
-
end # methods that do not interact with the API
|
86
|
-
|
87
|
-
|
88
|
-
describe "authentication and api requests" do
|
89
|
-
|
90
|
-
context "GET Requests" do
|
91
|
-
let(:current_tips) { [{"amount"=>"1.00", "platform"=>"gittip", "username"=>"whit537"},
|
92
|
-
{"amount"=>"0.25", "platform"=>"gittip", "username"=>"JohnKellyFerguson"}] }
|
93
60
|
|
94
|
-
|
95
|
-
|
96
|
-
|
61
|
+
it "updates the correct tip information" do
|
62
|
+
expect(
|
63
|
+
client.update_tips(
|
64
|
+
[{ :username => "whit537", :amount => "10" },
|
65
|
+
{ :username => "JohnKellyFerguson", :amount => "4"}]
|
66
|
+
).parsed_response).to eq(multi_tip_response)
|
67
|
+
end
|
68
|
+
end # updating multiple tips
|
97
69
|
|
98
|
-
|
99
|
-
VCR.eject_cassette
|
100
|
-
end
|
70
|
+
end #update_tips
|
101
71
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
72
|
+
describe "#update_tips_and_prune" do
|
73
|
+
let(:previous_tips) do
|
74
|
+
[
|
75
|
+
{"amount"=>"1.00", "platform"=>"gittip", "username"=>"whit537"},
|
76
|
+
{"amount"=>"0.25", "platform"=>"gittip", "username"=>"JohnKellyFerguson"}
|
77
|
+
]
|
106
78
|
end
|
107
|
-
|
108
|
-
|
109
|
-
it "returns the correct total of current tips" do
|
110
|
-
expect(client.current_tips_total).to eq(1.25)
|
111
|
-
end
|
79
|
+
let(:pruned_tips) do
|
80
|
+
[{ "amount"=>"1.00", "platform"=>"gittip", "username"=>"whit537" }]
|
112
81
|
end
|
113
|
-
end #GET Requests
|
114
|
-
|
115
|
-
context "POST Requests" do
|
116
|
-
|
117
|
-
describe "#update_tips" do
|
118
|
-
|
119
|
-
context "when updating a single tip" do
|
120
|
-
let(:single_tip_response) { [{"amount"=>"5", "platform"=>"gittip", "username"=>"whit537"}] }
|
121
|
-
|
122
|
-
before do
|
123
|
-
VCR.insert_cassette "post_single_tip"
|
124
|
-
end
|
125
|
-
|
126
|
-
after do
|
127
|
-
VCR.eject_cassette
|
128
|
-
end
|
129
82
|
|
130
|
-
|
131
|
-
|
132
|
-
client.update_tips(
|
133
|
-
[{ :username => "whit537", :amount => "5" }]
|
134
|
-
).parsed_response).to eq(single_tip_response)
|
135
|
-
end
|
136
|
-
end #updating a single tip
|
137
|
-
|
138
|
-
context "when updating multiple tips" do
|
139
|
-
let(:multi_tip_response) { [
|
140
|
-
{"amount"=>"10", "platform"=>"gittip", "username"=>"whit537"},
|
141
|
-
{"amount"=>"4", "platform"=>"gittip", "username"=>"JohnKellyFerguson"}
|
142
|
-
] }
|
143
|
-
|
144
|
-
before do
|
145
|
-
VCR.insert_cassette "post_multiple_tips"
|
146
|
-
end
|
147
|
-
|
148
|
-
after do
|
149
|
-
VCR.eject_cassette
|
150
|
-
end
|
151
|
-
|
152
|
-
it "updates the correct tip information" do
|
153
|
-
expect(
|
154
|
-
client.update_tips(
|
155
|
-
[{ :username => "whit537", :amount => "10" },
|
156
|
-
{ :username => "JohnKellyFerguson", :amount => "4"}]
|
157
|
-
).parsed_response).to eq(multi_tip_response)
|
158
|
-
end
|
159
|
-
end # updating multiple tips
|
160
|
-
|
161
|
-
# context "when passing in a non-existent username" do
|
162
|
-
# before do
|
163
|
-
# VCR.insert_cassette "post_tip_error"
|
164
|
-
# end
|
165
|
-
|
166
|
-
# after do
|
167
|
-
# VCR.eject_cassette
|
168
|
-
# end
|
169
|
-
|
170
|
-
# it "raises an error" do
|
171
|
-
# expect(
|
172
|
-
# client.update_tips(
|
173
|
-
# [ {:username => "not_a_real_user", :amount => "20"} ]
|
174
|
-
# ).parsed_response).to eq()
|
175
|
-
# end
|
176
|
-
# end # non-existent username
|
177
|
-
|
178
|
-
end #update_tips
|
179
|
-
|
180
|
-
describe "#update_tips_and_prune" do
|
83
|
+
before { VCR.insert_cassette "update_and_prune" }
|
84
|
+
after { VCR.eject_cassette }
|
181
85
|
|
86
|
+
it "removes tips that were not part of the request" do
|
87
|
+
expect { client.update_tips_and_prune(pruned_tips) }
|
88
|
+
.to change { client.current_tips }
|
89
|
+
.from(previous_tips).to(pruned_tips)
|
182
90
|
end
|
183
91
|
|
184
|
-
end
|
92
|
+
end
|
185
93
|
|
186
|
-
end #
|
94
|
+
end #POST Requests
|
187
95
|
end
|
data/spec/spec_helper.rb
CHANGED