gratitude 0.0.10 → 0.0.11

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.
@@ -3,13 +3,8 @@ require "spec_helper"
3
3
  describe Gratitude::Statistics do
4
4
 
5
5
  describe "default attributes" do
6
- it "includes httparty methods" do
7
- expect(Gratitude::Statistics).to include(HTTParty)
8
- end
9
-
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")
6
+ it "includes Gratitude::Connection" do
7
+ expect(Gratitude::Statistics).to include(Gratitude::Connection)
13
8
  end
14
9
  end
15
10
 
@@ -18,15 +13,36 @@ describe Gratitude::Statistics do
18
13
  after { VCR.eject_cassette }
19
14
  let(:stats) { Gratitude::Statistics.current }
20
15
 
21
- it "responds to #repsonse" do
22
- expect(stats).to respond_to(:response)
16
+ describe "json response" do
17
+ it "returns the correct keys in the json hash" do
18
+ expect(stats.send(:response_body).keys)
19
+ .to eq(
20
+ [
21
+ "average_tip",
22
+ "average_tippees",
23
+ "escrow",
24
+ "last_thursday",
25
+ "nach",
26
+ "nactive",
27
+ "ncc",
28
+ "ngivers",
29
+ "noverlap",
30
+ "nreceivers",
31
+ "other_people",
32
+ "pcc",
33
+ "punc",
34
+ "statements",
35
+ "this_thursday",
36
+ "tip_distribution_json",
37
+ "tip_n",
38
+ "total_backed_tips",
39
+ "transfer_volume"
40
+ ]
41
+ )
42
+ end
23
43
  end
24
44
 
25
45
  describe "#average_tip_amount" do
26
- it "returns the correct average tip amount" do
27
- expect(stats.average_tip_amount).to eq(1.2348237280979524)
28
- end
29
-
30
46
  it "returns a float" do
31
47
  expect(stats.average_tip_amount.class).to be(Float)
32
48
  end
@@ -37,10 +53,6 @@ describe Gratitude::Statistics do
37
53
  end
38
54
 
39
55
  describe "#average_number_of_tippees" do
40
- it "returns the correct average number of tippees" do
41
- expect(stats.average_number_of_tippees).to eq(3)
42
- end
43
-
44
56
  it "returns a fixnum" do
45
57
  expect(stats.average_number_of_tippees.class).to be(Fixnum)
46
58
  end
@@ -51,10 +63,6 @@ describe Gratitude::Statistics do
51
63
  end
52
64
 
53
65
  describe "#amount_in_escrow" do
54
- it "returns the correct amount in escrow" do
55
- expect(stats.amount_in_escrow).to eq(50441.17)
56
- end
57
-
58
66
  it "returns a float" do
59
67
  expect(stats.amount_in_escrow.class).to be(Float)
60
68
  end
@@ -65,20 +73,12 @@ describe Gratitude::Statistics do
65
73
  end
66
74
 
67
75
  describe "#last_thursday" do
68
- it "returns the correct value for last thursday" do
69
- expect(stats.last_thursday).to eq("last Thursday")
70
- end
71
-
72
76
  it "returns a string" do
73
77
  expect(stats.last_thursday.class).to be(String)
74
78
  end
75
79
  end
76
80
 
77
81
  describe "#number_of_achs" do
78
- it "returns the correct number of ach credits" do
79
- expect(stats.number_of_ach_credits).to eq(299)
80
- end
81
-
82
82
  it "returns a fixnum" do
83
83
  expect(stats.number_of_ach_credits.class).to be(Fixnum)
84
84
  end
@@ -93,10 +93,6 @@ describe Gratitude::Statistics do
93
93
  end
94
94
 
95
95
  describe "#number_of_active_users" do
96
- it "returns the correct number of active users" do
97
- expect(stats.number_of_active_users).to eq(1719)
98
- end
99
-
100
96
  it "returns a fixnum" do
101
97
  expect(stats.number_of_active_users.class).to be(Fixnum)
102
98
  end
@@ -107,10 +103,6 @@ describe Gratitude::Statistics do
107
103
  end
108
104
 
109
105
  describe "#number_of_credit_cards" do
110
- it "returns the correct number of credit cards on file" do
111
- expect(stats.number_of_credit_cards).to eq(1496)
112
- end
113
-
114
106
  it "returns a fixnum" do
115
107
  expect(stats.number_of_credit_cards.class).to be(Fixnum)
116
108
  end
@@ -121,10 +113,6 @@ describe Gratitude::Statistics do
121
113
  end
122
114
 
123
115
  describe "#number_of_givers" do
124
- it "returns the correct number of givers" do
125
- expect(stats.number_of_givers).to eq(1113)
126
- end
127
-
128
116
  it "returns a fixnum" do
129
117
  expect(stats.number_of_givers.class).to be(Fixnum)
130
118
  end
@@ -135,10 +123,6 @@ describe Gratitude::Statistics do
135
123
  end
136
124
 
137
125
  describe "#number_who_give_and_receive" do
138
- it "returns the correct number of users who both give and receive" do
139
- expect(stats.number_who_give_and_receive).to eq(301)
140
- end
141
-
142
126
  it "returns a fixnum" do
143
127
  expect(stats.number_who_give_and_receive.class).to be(Fixnum)
144
128
  end
@@ -149,10 +133,6 @@ describe Gratitude::Statistics do
149
133
  end
150
134
 
151
135
  describe "#number_of_receivers" do
152
- it "returns the correct number of receivers" do
153
- expect(stats.number_of_receivers).to eq(907)
154
- end
155
-
156
136
  it "returns a fixnum" do
157
137
  expect(stats.number_of_receivers.class).to be(Fixnum)
158
138
  end
@@ -163,20 +143,12 @@ describe Gratitude::Statistics do
163
143
  end
164
144
 
165
145
  describe "#other_people" do
166
- it "returns the correct value for #other_people" do
167
- expect(stats.other_people).to eq("three other people")
168
- end
169
-
170
146
  it "returns a string" do
171
147
  expect(stats.other_people.class).to be(String)
172
148
  end
173
149
  end
174
150
 
175
151
  describe "#percentage_of_users_with_credit_cards" do
176
- it "returns the correct value for #percentage_of_users_with_credit_cards" do
177
- expect(stats.percentage_of_users_with_credit_cards).to eq("7.6")
178
- end
179
-
180
152
  it "returns a string" do
181
153
  expect(stats.percentage_of_users_with_credit_cards.class).to be(String)
182
154
  end
@@ -187,10 +159,6 @@ describe Gratitude::Statistics do
187
159
  end
188
160
 
189
161
  describe "#punctuation" do
190
- it "returns the correct value for #punctuation" do
191
- expect(stats.punctuation).to eq(".")
192
- end
193
-
194
162
  it "returns a string" do
195
163
  expect(stats.punctuation.class).to be(String)
196
164
  end
@@ -214,19 +182,19 @@ describe Gratitude::Statistics do
214
182
  end
215
183
 
216
184
  it "has statement as a key in each hash element" do
217
- expect(stats.statements.first.has_key?("statement")).to be(true)
185
+ stats.statements.each do |statement|
186
+ expect(statement.has_key?("statement")).to be(true)
187
+ end
218
188
  end
219
189
 
220
190
  it "has username as a key in each hash element" do
221
- expect(stats.statements.first.has_key?("username")).to be(true)
191
+ stats.statements.each do |statement|
192
+ expect(statement.has_key?("username")).to be(true)
193
+ end
222
194
  end
223
195
  end
224
196
 
225
197
  describe "#this_thursday" do
226
- it "returns the correct value for this thursday" do
227
- expect(stats.this_thursday).to eq("this Thursday")
228
- end
229
-
230
198
  it "returns a string" do
231
199
  expect(stats.this_thursday.class).to be(String)
232
200
  end
@@ -239,10 +207,6 @@ describe Gratitude::Statistics do
239
207
  end
240
208
 
241
209
  describe "#number_of_tips" do
242
- it "returns the correct number of tips" do
243
- expect(stats.number_of_tips).to eq(4710)
244
- end
245
-
246
210
  it "returns a fixnum" do
247
211
  expect(stats.number_of_tips.class).to be(Fixnum)
248
212
  end
@@ -253,10 +217,6 @@ describe Gratitude::Statistics do
253
217
  end
254
218
 
255
219
  describe "#value_of_total_backed_tips" do
256
- it "returns the correct value of total backed tips" do
257
- expect(stats.value_of_total_backed_tips).to eq(5849.36)
258
- end
259
-
260
220
  it "returns a float" do
261
221
  expect(stats.value_of_total_backed_tips.class).to be(Float)
262
222
  end
@@ -267,14 +227,10 @@ describe Gratitude::Statistics do
267
227
  end
268
228
 
269
229
  describe "#transfer_volume" do
270
- it "returns the correct transfer volume" do
271
- expect(stats.transfer_volume).to eq(5464.38)
272
- end
273
-
274
230
  it "returns a float" do
275
231
  expect(stats.transfer_volume.class).to be(Float)
276
232
  end
277
233
  end
278
234
  end
279
235
 
280
- end
236
+ end
@@ -8,7 +8,7 @@ describe Gratitude::Client::Tips do
8
8
  end
9
9
 
10
10
  describe "GET Requests" do
11
- before { VCR.insert_cassette "get_tips" }
11
+ before { VCR.insert_cassette "current_tips" }
12
12
  after { VCR.eject_cassette }
13
13
  let(:current_tips) do
14
14
  [
@@ -32,63 +32,45 @@ describe Gratitude::Client::Tips do
32
32
 
33
33
  describe "POST Requests" do
34
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"}]
40
- end
41
-
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)
47
- end
48
- end #update_tips
49
-
50
- context "when updating multiple tips" do
51
- before { VCR.insert_cassette "post_multiple_tips" }
52
- after { VCR.eject_cassette }
53
-
54
- let(:multi_tip_response) do
55
- [
56
- {"amount"=>"10", "platform"=>"gittip", "username"=>"whit537"},
57
- {"amount"=>"4", "platform"=>"gittip", "username"=>"JohnKellyFerguson"}
58
- ]
59
- end
35
+ before { VCR.insert_cassette "update_tips" }
36
+ after { VCR.eject_cassette }
60
37
 
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
38
+ let(:multiple_tips) do
39
+ [
40
+ {"amount"=>"1.00", "platform"=>"gittip", "username"=>"whit537"},
41
+ {"amount"=>"0.25", "platform"=>"gittip", "username"=>"JohnKellyFerguson"},
42
+ {"amount"=>"1.00", "platform"=>"gittip", "username"=>"Gittip"}
43
+ ]
44
+ end
69
45
 
46
+ it "updates the correct tip information" do
47
+ expect(client.update_tips(multiple_tips)).to eq(multiple_tips)
48
+ end
70
49
  end #update_tips
71
50
 
72
51
  describe "#update_tips_and_prune" do
52
+ before { VCR.insert_cassette "update_and_prune" }
53
+ after { VCR.eject_cassette }
54
+
73
55
  let(:previous_tips) do
74
56
  [
75
57
  {"amount"=>"1.00", "platform"=>"gittip", "username"=>"whit537"},
76
- {"amount"=>"0.25", "platform"=>"gittip", "username"=>"JohnKellyFerguson"}
58
+ {"amount"=>"0.25", "platform"=>"gittip", "username"=>"JohnKellyFerguson"},
59
+ {"amount"=>"1.00", "platform"=>"gittip", "username"=>"Gittip"}
77
60
  ]
78
61
  end
79
62
  let(:pruned_tips) do
80
- [{ "amount"=>"1.00", "platform"=>"gittip", "username"=>"whit537" }]
63
+ [
64
+ {"amount"=>"1.00", "platform"=>"gittip", "username"=>"whit537"},
65
+ {"amount"=>"0.25", "platform"=>"gittip", "username"=>"JohnKellyFerguson"}
66
+ ]
81
67
  end
82
68
 
83
- before { VCR.insert_cassette "update_and_prune" }
84
- after { VCR.eject_cassette }
85
-
86
69
  it "removes tips that were not part of the request" do
87
70
  expect { client.update_tips_and_prune(pruned_tips) }
88
71
  .to change { client.current_tips }
89
- .from(previous_tips).to(pruned_tips)
72
+ .to(pruned_tips)
90
73
  end
91
-
92
74
  end
93
75
 
94
76
  end #POST Requests
data/spec/spec_helper.rb CHANGED
@@ -16,4 +16,5 @@ VCR.configure do |c|
16
16
  c.cassette_library_dir = 'spec/cassettes'
17
17
  c.hook_into :webmock
18
18
  c.default_cassette_options = { record: :new_episodes, serialize_with: :json }
19
+ c.default_cassette_options = { re_record_interval: 604800 }
19
20
  end
metadata CHANGED
@@ -1,29 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gratitude
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Kelly Ferguson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-27 00:00:00.000000000 Z
11
+ date: 2014-03-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: httparty
14
+ name: faraday
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.11'
19
+ version: '0.8'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.11'
26
+ version: '0.8'
27
+ - !ruby/object:Gem::Dependency
28
+ name: faraday_middleware
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.9'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.9'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: json
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -44,14 +58,14 @@ dependencies:
44
58
  requirements:
45
59
  - - "~>"
46
60
  - !ruby/object:Gem::Version
47
- version: '1.3'
61
+ version: '1.6'
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
66
  - - "~>"
53
67
  - !ruby/object:Gem::Version
54
- version: '1.3'
68
+ version: '1.6'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: rake
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -78,6 +92,7 @@ files:
78
92
  - ".travis.yml"
79
93
  - CHANGELOG.md
80
94
  - Gemfile
95
+ - Guardfile
81
96
  - LICENSE.txt
82
97
  - README.md
83
98
  - Rakefile
@@ -85,22 +100,20 @@ files:
85
100
  - gratitude.gemspec
86
101
  - lib/gratitude.rb
87
102
  - lib/gratitude/client.rb
103
+ - lib/gratitude/connection.rb
88
104
  - lib/gratitude/payday.rb
89
105
  - lib/gratitude/profile.rb
90
106
  - lib/gratitude/statistics.rb
91
107
  - lib/gratitude/tips.rb
92
108
  - lib/gratitude/version.rb
93
- - spec/cassettes/complete_profile.json
94
- - spec/cassettes/get_tips.json
95
- - spec/cassettes/goal_profile.json
96
- - spec/cassettes/incomplete_profile.json
109
+ - spec/cassettes/current_tips.json
97
110
  - spec/cassettes/paydays.json
98
- - spec/cassettes/post_multiple_tips.json
99
- - spec/cassettes/post_single_tip.json
100
- - spec/cassettes/post_tip_error.json
111
+ - spec/cassettes/profiles.json
101
112
  - spec/cassettes/statistics.json
102
113
  - spec/cassettes/update_and_prune.json
114
+ - spec/cassettes/update_tips.json
103
115
  - spec/gratitude/client_spec.rb
116
+ - spec/gratitude/connection_spec.rb
104
117
  - spec/gratitude/payday_spec.rb
105
118
  - spec/gratitude/profile_spec.rb
106
119
  - spec/gratitude/statistics_spec.rb
@@ -132,17 +145,14 @@ signing_key:
132
145
  specification_version: 4
133
146
  summary: A simple Ruby wrapper for the Gittip API.
134
147
  test_files:
135
- - spec/cassettes/complete_profile.json
136
- - spec/cassettes/get_tips.json
137
- - spec/cassettes/goal_profile.json
138
- - spec/cassettes/incomplete_profile.json
148
+ - spec/cassettes/current_tips.json
139
149
  - spec/cassettes/paydays.json
140
- - spec/cassettes/post_multiple_tips.json
141
- - spec/cassettes/post_single_tip.json
142
- - spec/cassettes/post_tip_error.json
150
+ - spec/cassettes/profiles.json
143
151
  - spec/cassettes/statistics.json
144
152
  - spec/cassettes/update_and_prune.json
153
+ - spec/cassettes/update_tips.json
145
154
  - spec/gratitude/client_spec.rb
155
+ - spec/gratitude/connection_spec.rb
146
156
  - spec/gratitude/payday_spec.rb
147
157
  - spec/gratitude/profile_spec.rb
148
158
  - spec/gratitude/statistics_spec.rb