candy_check 0.4.0 → 0.6.0

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 (66) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/build.yml +35 -0
  3. data/.rubocop.yml +10 -0
  4. data/.ruby-version +1 -1
  5. data/Gemfile +1 -1
  6. data/Guardfile +5 -3
  7. data/README.md +2 -2
  8. data/Rakefile +5 -5
  9. data/candy_check.gemspec +14 -12
  10. data/lib/candy_check/app_store/client.rb +7 -7
  11. data/lib/candy_check/app_store/config.rb +7 -9
  12. data/lib/candy_check/app_store/receipt.rb +16 -16
  13. data/lib/candy_check/app_store/receipt_collection.rb +2 -2
  14. data/lib/candy_check/app_store/subscription_verification.rb +5 -5
  15. data/lib/candy_check/app_store/verification.rb +3 -3
  16. data/lib/candy_check/app_store/verification_failure.rb +25 -21
  17. data/lib/candy_check/app_store/verifier.rb +4 -5
  18. data/lib/candy_check/app_store.rb +8 -8
  19. data/lib/candy_check/cli/app.rb +3 -3
  20. data/lib/candy_check/cli/commands/app_store.rb +1 -1
  21. data/lib/candy_check/cli/commands.rb +4 -4
  22. data/lib/candy_check/cli/out.rb +1 -3
  23. data/lib/candy_check/cli.rb +3 -3
  24. data/lib/candy_check/play_store/product_acknowledgements/acknowledgement.rb +2 -1
  25. data/lib/candy_check/play_store/product_purchases/product_purchase.rb +3 -3
  26. data/lib/candy_check/play_store/product_purchases/product_verification.rb +1 -1
  27. data/lib/candy_check/play_store/subscription_purchases/subscription_purchase.rb +2 -1
  28. data/lib/candy_check/play_store/subscription_purchases/subscription_verification.rb +1 -0
  29. data/lib/candy_check/play_store/verification_failure.rb +2 -2
  30. data/lib/candy_check/play_store.rb +2 -1
  31. data/lib/candy_check/utils/attribute_reader.rb +3 -2
  32. data/lib/candy_check/utils/config.rb +2 -0
  33. data/lib/candy_check/utils.rb +2 -2
  34. data/lib/candy_check/version.rb +1 -1
  35. data/lib/candy_check.rb +4 -4
  36. data/spec/app_store/client_spec.rb +18 -18
  37. data/spec/app_store/config_spec.rb +9 -9
  38. data/spec/app_store/receipt_collection_spec.rb +39 -41
  39. data/spec/app_store/receipt_spec.rb +47 -47
  40. data/spec/app_store/subscription_verification_spec.rb +35 -32
  41. data/spec/app_store/verifcation_failure_spec.rb +7 -7
  42. data/spec/app_store/verification_spec.rb +23 -11
  43. data/spec/app_store/verifier_spec.rb +40 -48
  44. data/spec/cli/app_spec.rb +11 -13
  45. data/spec/cli/commands/app_store_spec.rb +22 -23
  46. data/spec/cli/commands/play_store_spec.rb +3 -1
  47. data/spec/cli/commands/version_spec.rb +2 -2
  48. data/spec/cli/out_spec.rb +9 -9
  49. data/spec/fixtures/vcr_cassettes/play_store/product_acknowledgements/acknowledged.yml +1 -1
  50. data/spec/fixtures/vcr_cassettes/play_store/product_acknowledgements/already_acknowledged.yml +1 -1
  51. data/spec/fixtures/vcr_cassettes/play_store/product_acknowledgements/refunded.yml +1 -1
  52. data/spec/fixtures/vcr_cassettes/play_store/product_purchases/permission_denied.yml +2 -2
  53. data/spec/fixtures/vcr_cassettes/play_store/product_purchases/response_with_empty_body.yml +2 -2
  54. data/spec/fixtures/vcr_cassettes/play_store/product_purchases/valid_but_not_consumed.yml +1 -1
  55. data/spec/fixtures/vcr_cassettes/play_store/subscription_purchases/permission_denied.yml +2 -2
  56. data/spec/fixtures/vcr_cassettes/play_store/subscription_purchases/valid_but_expired.yml +1 -1
  57. data/spec/play_store/acknowledger_spec.rb +4 -0
  58. data/spec/play_store/product_acknowledgements/acknowledgement_spec.rb +4 -0
  59. data/spec/play_store/product_acknowledgements/response_spec.rb +16 -15
  60. data/spec/play_store/product_purchases/product_purchase_spec.rb +6 -27
  61. data/spec/play_store/subscription_purchases/subscription_purchase_spec.rb +22 -46
  62. data/spec/play_store/verification_failure_spec.rb +6 -4
  63. data/spec/play_store/verifier_spec.rb +4 -2
  64. data/spec/spec_helper.rb +20 -9
  65. metadata +91 -63
  66. data/.travis.yml +0 -18
@@ -55,7 +55,7 @@ http_interactions:
55
55
  recorded_at: Fri, 04 Oct 2019 13:11:23 GMT
56
56
  - request:
57
57
  method: get
58
- uri: https://www.googleapis.com/androidpublisher/v3/applications/my_package_name/purchases/products/my_product_id/tokens/my_token
58
+ uri: https://androidpublisher.googleapis.com/androidpublisher/v3/applications/my_package_name/purchases/products/my_product_id/tokens/my_token
59
59
  body:
60
60
  encoding: UTF-8
61
61
  string: ''
@@ -125,7 +125,7 @@ http_interactions:
125
125
  recorded_at: Fri, 04 Oct 2019 13:11:24 GMT
126
126
  - request:
127
127
  method: get
128
- uri: https://www.googleapis.com/androidpublisher/v3/applications/my_package_name/purchases/products/my_product_id/tokens/my_token
128
+ uri: https://androidpublisher.googleapis.com/androidpublisher/v3/applications/my_package_name/purchases/products/my_product_id/tokens/my_token
129
129
  body:
130
130
  encoding: UTF-8
131
131
  string: ''
@@ -55,7 +55,7 @@ http_interactions:
55
55
  recorded_at: Fri, 04 Oct 2019 13:11:23 GMT
56
56
  - request:
57
57
  method: get
58
- uri: https://www.googleapis.com/androidpublisher/v3/applications/my_package_name/purchases/products/my_product_id/tokens/my_token
58
+ uri: https://androidpublisher.googleapis.com/androidpublisher/v3/applications/my_package_name/purchases/products/my_product_id/tokens/my_token
59
59
  body:
60
60
  encoding: UTF-8
61
61
  string: ''
@@ -125,7 +125,7 @@ http_interactions:
125
125
  recorded_at: Fri, 04 Oct 2019 13:11:24 GMT
126
126
  - request:
127
127
  method: get
128
- uri: https://www.googleapis.com/androidpublisher/v3/applications/my_package_name/purchases/products/my_product_id/tokens/my_token
128
+ uri: https://androidpublisher.googleapis.com/androidpublisher/v3/applications/my_package_name/purchases/products/my_product_id/tokens/my_token
129
129
  body:
130
130
  encoding: UTF-8
131
131
  string: ''
@@ -55,7 +55,7 @@ http_interactions:
55
55
  recorded_at: Fri, 04 Oct 2019 09:25:53 GMT
56
56
  - request:
57
57
  method: get
58
- uri: https://www.googleapis.com/androidpublisher/v3/applications/my_package_name/purchases/products/my_product_id/tokens/my_token
58
+ uri: https://androidpublisher.googleapis.com/androidpublisher/v3/applications/my_package_name/purchases/products/my_product_id/tokens/my_token
59
59
  body:
60
60
  encoding: UTF-8
61
61
  string: ''
@@ -55,7 +55,7 @@ http_interactions:
55
55
  recorded_at: Thu, 10 Oct 2019 14:07:52 GMT
56
56
  - request:
57
57
  method: get
58
- uri: https://www.googleapis.com/androidpublisher/v3/applications/my_package_name/purchases/subscriptions/my_subscription_id/tokens/my_token
58
+ uri: https://androidpublisher.googleapis.com/androidpublisher/v3/applications/my_package_name/purchases/subscriptions/my_subscription_id/tokens/my_token
59
59
  body:
60
60
  encoding: UTF-8
61
61
  string: ''
@@ -125,7 +125,7 @@ http_interactions:
125
125
  recorded_at: Thu, 10 Oct 2019 14:07:52 GMT
126
126
  - request:
127
127
  method: get
128
- uri: https://www.googleapis.com/androidpublisher/v3/applications/my_package_name/purchases/subscriptions/my_subscription_id/tokens/my_token
128
+ uri: https://androidpublisher.googleapis.com/androidpublisher/v3/applications/my_package_name/purchases/subscriptions/my_subscription_id/tokens/my_token
129
129
  body:
130
130
  encoding: UTF-8
131
131
  string: ''
@@ -55,7 +55,7 @@ http_interactions:
55
55
  recorded_at: Thu, 24 Oct 2019 10:43:13 GMT
56
56
  - request:
57
57
  method: get
58
- uri: https://www.googleapis.com/androidpublisher/v3/applications/my_package_name/purchases/subscriptions/my_subscription_id/tokens/my_token
58
+ uri: https://androidpublisher.googleapis.com/androidpublisher/v3/applications/my_package_name/purchases/subscriptions/my_subscription_id/tokens/my_token
59
59
  body:
60
60
  encoding: UTF-8
61
61
  string: ''
@@ -21,7 +21,9 @@ describe CandyCheck::PlayStore::Acknowledger do
21
21
  end
22
22
  end
23
23
  it "when already acknowledged" do
24
+ # rubocop:disable Layout/LineLength
24
25
  error_body = "{\n \"error\": {\n \"code\": 400,\n \"message\": \"The purchase is not in a valid state to perform the desired operation.\",\n \"errors\": [\n {\n \"message\": \"The purchase is not in a valid state to perform the desired operation.\",\n \"domain\": \"androidpublisher\",\n \"reason\": \"invalidPurchaseState\",\n \"location\": \"token\",\n \"locationType\": \"parameter\"\n }\n ]\n }\n}\n"
26
+ # rubocop:enable Layout/LineLength
25
27
 
26
28
  VCR.use_cassette("play_store/product_acknowledgements/already_acknowledged") do
27
29
  result = subject.acknowledge_product_purchase(package_name: package_name, product_id: product_id, token: token)
@@ -33,7 +35,9 @@ describe CandyCheck::PlayStore::Acknowledger do
33
35
  end
34
36
  end
35
37
  it "when it has been refunded" do
38
+ # rubocop:disable Layout/LineLength
36
39
  error_body = "{\n \"error\": {\n \"code\": 400,\n \"message\": \"The product purchase is not owned by the user.\",\n \"errors\": [\n {\n \"message\": \"The product purchase is not owned by the user.\",\n \"domain\": \"androidpublisher\",\n \"reason\": \"productNotOwnedByUser\"\n }\n ]\n }\n}\n"
40
+ # rubocop:enable Layout/LineLength
37
41
 
38
42
  VCR.use_cassette("play_store/product_acknowledgements/refunded") do
39
43
  result = subject.acknowledge_product_purchase(package_name: package_name, product_id: product_id, token: token)
@@ -27,7 +27,9 @@ describe CandyCheck::PlayStore::ProductAcknowledgements::Acknowledgement do
27
27
  end
28
28
  end
29
29
  it "when already acknowledged" do
30
+ # rubocop:disable Layout/LineLength
30
31
  error_body = "{\n \"error\": {\n \"code\": 400,\n \"message\": \"The purchase is not in a valid state to perform the desired operation.\",\n \"errors\": [\n {\n \"message\": \"The purchase is not in a valid state to perform the desired operation.\",\n \"domain\": \"androidpublisher\",\n \"reason\": \"invalidPurchaseState\",\n \"location\": \"token\",\n \"locationType\": \"parameter\"\n }\n ]\n }\n}\n"
32
+ # rubocop:enable Layout/LineLength
31
33
 
32
34
  VCR.use_cassette("play_store/product_acknowledgements/already_acknowledged") do
33
35
  result = subject.call!
@@ -39,7 +41,9 @@ describe CandyCheck::PlayStore::ProductAcknowledgements::Acknowledgement do
39
41
  end
40
42
  end
41
43
  it "when it has been refunded" do
44
+ # rubocop:disable Layout/LineLength
42
45
  error_body = "{\n \"error\": {\n \"code\": 400,\n \"message\": \"The product purchase is not owned by the user.\",\n \"errors\": [\n {\n \"message\": \"The product purchase is not owned by the user.\",\n \"domain\": \"androidpublisher\",\n \"reason\": \"productNotOwnedByUser\"\n }\n ]\n }\n}\n"
46
+ # rubocop:enable Layout/LineLength
43
47
 
44
48
  VCR.use_cassette("play_store/product_acknowledgements/refunded") do
45
49
  result = subject.call!
@@ -5,23 +5,23 @@ describe CandyCheck::PlayStore::ProductAcknowledgements::Response do
5
5
  CandyCheck::PlayStore::ProductAcknowledgements::Response.new(result: result, error_data: error_data)
6
6
  end
7
7
 
8
- describe '#acknowledged?' do
9
- context 'when result present' do
10
- let(:result) { '' }
8
+ describe "#acknowledged?" do
9
+ context "when result present" do
10
+ let(:result) { "" }
11
11
  let(:error_data) { nil }
12
12
 
13
- it 'returns true' do
13
+ it "returns true" do
14
14
  result = subject.acknowledged?
15
15
 
16
16
  _(result).must_be_true
17
17
  end
18
18
  end
19
19
 
20
- context 'when result is not present' do
20
+ context "when result is not present" do
21
21
  let(:result) { nil }
22
- let(:error_data) { nil }
22
+ let(:error_data) { nil }
23
23
 
24
- it 'returns false' do
24
+ it "returns false" do
25
25
  result = subject.acknowledged?
26
26
 
27
27
  _(result).must_be_false
@@ -29,34 +29,35 @@ describe CandyCheck::PlayStore::ProductAcknowledgements::Response do
29
29
  end
30
30
  end
31
31
 
32
- describe '#error' do
33
- context 'when error present' do
32
+ describe "#error" do
33
+ context "when error present" do
34
34
  let(:result) { nil }
35
35
  let(:error_data) do
36
36
  Module.new do
37
37
  def status_code
38
38
  400
39
39
  end
40
+
40
41
  def body
41
- 'A String describing the issue'
42
+ "A String describing the issue"
42
43
  end
43
44
  module_function :status_code, :body
44
45
  end
45
46
  end
46
47
 
47
- it 'returns the expected data' do
48
+ it "returns the expected data" do
48
49
  result = subject.error
49
50
 
50
51
  _(result[:status_code]).must_equal(400)
51
- _(result[:body]).must_equal('A String describing the issue')
52
+ _(result[:body]).must_equal("A String describing the issue")
52
53
  end
53
54
  end
54
55
 
55
- context 'when error is not present' do
56
- let(:result) { '' }
56
+ context "when error is not present" do
57
+ let(:result) { "" }
57
58
  let(:error_data) { nil }
58
59
 
59
- it 'returns false' do
60
+ it "returns false" do
60
61
  result = subject.error
61
62
 
62
63
  _(result).must_be_nil
@@ -5,13 +5,13 @@ describe CandyCheck::PlayStore::ProductPurchases::ProductPurchase do
5
5
 
6
6
  describe "valid and non-consumed product" do
7
7
  let(:fake_product_purchase) do
8
- FakeProductPurchase.new(
8
+ OpenStruct.new(
9
9
  consumption_state: 0,
10
10
  developer_payload: "payload that gets stored and returned",
11
11
  kind: "androidpublisher#productPurchase",
12
12
  order_id: "ABC123",
13
13
  purchase_state: 0,
14
- purchase_time_millis: 1421676237413,
14
+ purchase_time_millis: 1_421_676_237_413,
15
15
  )
16
16
  end
17
17
 
@@ -51,13 +51,13 @@ describe CandyCheck::PlayStore::ProductPurchases::ProductPurchase do
51
51
 
52
52
  describe "valid and consumed product" do
53
53
  let(:fake_product_purchase) do
54
- FakeProductPurchase.new(
54
+ OpenStruct.new(
55
55
  consumption_state: 1,
56
56
  developer_payload: "payload that gets stored and returned",
57
57
  kind: "androidpublisher#productPurchase",
58
58
  order_id: "ABC123",
59
59
  purchase_state: 0,
60
- purchase_time_millis: 1421676237413,
60
+ purchase_time_millis: 1_421_676_237_413,
61
61
  )
62
62
  end
63
63
 
@@ -72,13 +72,13 @@ describe CandyCheck::PlayStore::ProductPurchases::ProductPurchase do
72
72
 
73
73
  describe "non-valid product" do
74
74
  let(:fake_product_purchase) do
75
- FakeProductPurchase.new(
75
+ OpenStruct.new(
76
76
  consumption_state: 0,
77
77
  developer_payload: "payload that gets stored and returned",
78
78
  kind: "androidpublisher#productPurchase",
79
79
  order_id: "ABC123",
80
80
  purchase_state: 1,
81
- purchase_time_millis: 1421676237413,
81
+ purchase_time_millis: 1_421_676_237_413,
82
82
  )
83
83
  end
84
84
 
@@ -86,25 +86,4 @@ describe CandyCheck::PlayStore::ProductPurchases::ProductPurchase do
86
86
  _(subject.valid?).must_be_false
87
87
  end
88
88
  end
89
-
90
- private
91
-
92
- class FakeProductPurchase
93
- FIELDS = [
94
- :consumption_state,
95
- :developer_payload,
96
- :kind,
97
- :order_id,
98
- :purchase_state,
99
- :purchase_time_millis,
100
- ].freeze
101
-
102
- attr_accessor *FIELDS
103
-
104
- def initialize(hash)
105
- FIELDS.each do |key|
106
- self.public_send("#{key}=", hash[key])
107
- end
108
- end
109
- end
110
89
  end
@@ -5,10 +5,10 @@ describe CandyCheck::PlayStore::SubscriptionPurchases::SubscriptionPurchase do
5
5
 
6
6
  describe "expired and canceled subscription" do
7
7
  let(:fake_subscription_purchase) do
8
- FakeSubscriptionPurchase.new(
8
+ OpenStruct.new(
9
9
  kind: "androidpublisher#subscriptionPurchase",
10
- start_time_millis: 1459540113244,
11
- expiry_time_millis: 1462132088610,
10
+ start_time_millis: 1_459_540_113_244,
11
+ expiry_time_millis: 1_462_132_088_610,
12
12
  auto_renewing: false,
13
13
  developer_payload: "payload that gets stored and returned",
14
14
  cancel_reason: 0,
@@ -66,10 +66,11 @@ describe CandyCheck::PlayStore::SubscriptionPurchases::SubscriptionPurchase do
66
66
 
67
67
  describe "unexpired and renewing subscription" do
68
68
  two_days_from_now = DateTime.now + 2
69
+
69
70
  let(:fake_subscription_purchase) do
70
- FakeSubscriptionPurchase.new(
71
+ OpenStruct.new(
71
72
  kind: "androidpublisher#subscriptionPurchase",
72
- start_time_millis: 1459540113244,
73
+ start_time_millis: 1_459_540_113_244,
73
74
  expiry_time_millis: (two_days_from_now.to_time.to_i * 1000),
74
75
  auto_renewing: true,
75
76
  developer_payload: "payload that gets stored and returned",
@@ -89,10 +90,10 @@ describe CandyCheck::PlayStore::SubscriptionPurchases::SubscriptionPurchase do
89
90
 
90
91
  describe "expired due to payment failure" do
91
92
  let(:fake_subscription_purchase) do
92
- FakeSubscriptionPurchase.new(
93
+ OpenStruct.new(
93
94
  kind: "androidpublisher#subscriptionPurchase",
94
- start_time_millis: 1459540113244,
95
- expiry_time_millis: 1462132088610,
95
+ start_time_millis: 1_459_540_113_244,
96
+ expiry_time_millis: 1_462_132_088_610,
96
97
  auto_renewing: true,
97
98
  developer_payload: "payload that gets stored and returned",
98
99
  cancel_reason: 1,
@@ -112,10 +113,10 @@ describe CandyCheck::PlayStore::SubscriptionPurchases::SubscriptionPurchase do
112
113
  describe "subscription cancelation by user" do
113
114
  describe "when subscription is not canceled" do
114
115
  let(:fake_subscription_purchase) do
115
- FakeSubscriptionPurchase.new(
116
+ OpenStruct.new(
116
117
  kind: "androidpublisher#subscriptionPurchase",
117
- start_time_millis: 1459540113244,
118
- expiry_time_millis: 1462132088610,
118
+ start_time_millis: 1_459_540_113_244,
119
+ expiry_time_millis: 1_462_132_088_610,
119
120
  auto_renewing: true,
120
121
  developer_payload: "payload that gets stored and returned",
121
122
  payment_state: 1,
@@ -137,11 +138,11 @@ describe CandyCheck::PlayStore::SubscriptionPurchases::SubscriptionPurchase do
137
138
 
138
139
  describe "when subscription is canceled" do
139
140
  let(:fake_subscription_purchase) do
140
- FakeSubscriptionPurchase.new(
141
+ OpenStruct.new(
141
142
  kind: "androidpublisher#subscriptionPurchase",
142
- start_time_millis: 1459540113244,
143
- expiry_time_millis: 1462132088610,
144
- user_cancellation_time_millis: 1461872888000,
143
+ start_time_millis: 1_459_540_113_244,
144
+ expiry_time_millis: 1_462_132_088_610,
145
+ user_cancellation_time_millis: 1_461_872_888_000,
145
146
  auto_renewing: true,
146
147
  developer_payload: "payload that gets stored and returned",
147
148
  cancel_reason: 0,
@@ -166,10 +167,10 @@ describe CandyCheck::PlayStore::SubscriptionPurchases::SubscriptionPurchase do
166
167
 
167
168
  describe "expired with pending payment" do
168
169
  let(:fake_subscription_purchase) do
169
- FakeSubscriptionPurchase.new(
170
+ OpenStruct.new(
170
171
  kind: "androidpublisher#subscriptionPurchase",
171
- start_time_millis: 1459540113244,
172
- expiry_time_millis: 1462132088610,
172
+ start_time_millis: 1_459_540_113_244,
173
+ expiry_time_millis: 1_462_132_088_610,
173
174
  auto_renewing: true,
174
175
  developer_payload: "payload that gets stored and returned",
175
176
  cancel_reason: 0,
@@ -188,10 +189,10 @@ describe CandyCheck::PlayStore::SubscriptionPurchases::SubscriptionPurchase do
188
189
 
189
190
  describe "trial" do
190
191
  let(:fake_subscription_purchase) do
191
- FakeSubscriptionPurchase.new(
192
+ OpenStruct.new(
192
193
  kind: "androidpublisher#subscriptionPurchase",
193
- start_time_millis: 1459540113244,
194
- expiry_time_millis: 1462132088610,
194
+ start_time_millis: 1_459_540_113_244,
195
+ expiry_time_millis: 1_462_132_088_610,
195
196
  auto_renewing: false,
196
197
  developer_payload: "payload that gets stored and returned",
197
198
  cancel_reason: 0,
@@ -209,29 +210,4 @@ describe CandyCheck::PlayStore::SubscriptionPurchases::SubscriptionPurchase do
209
210
  _(subject.price_currency_code).must_equal "SOMECODE"
210
211
  end
211
212
  end
212
-
213
- private
214
-
215
- class FakeSubscriptionPurchase
216
- FIELDS = [
217
- :kind,
218
- :start_time_millis,
219
- :expiry_time_millis,
220
- :user_cancellation_time_millis,
221
- :auto_renewing,
222
- :developer_payload,
223
- :cancel_reason,
224
- :payment_state,
225
- :price_amount_micros,
226
- :price_currency_code,
227
- ].freeze
228
-
229
- attr_accessor *FIELDS
230
-
231
- def initialize(hash)
232
- FIELDS.each do |key|
233
- self.public_send("#{key}=", hash[key])
234
- end
235
- end
236
- end
237
213
  end
@@ -3,9 +3,13 @@ require "spec_helper"
3
3
  describe CandyCheck::PlayStore::VerificationFailure do
4
4
  subject { CandyCheck::PlayStore::VerificationFailure.new(fake_error) }
5
5
 
6
+ let(:fake_error_class) do
7
+ Struct.new(:status_code, :message)
8
+ end
9
+
6
10
  describe "denied" do
7
11
  let(:fake_error) do
8
- FakeError.new("401", "The current user has insufficient permissions")
12
+ fake_error_class.new("401", "The current user has insufficient permissions")
9
13
  end
10
14
 
11
15
  it "returns the code" do
@@ -19,7 +23,7 @@ describe CandyCheck::PlayStore::VerificationFailure do
19
23
 
20
24
  describe "empty" do
21
25
  let(:fake_error) do
22
- FakeError.new(nil, nil)
26
+ fake_error_class.new(nil, nil)
23
27
  end
24
28
 
25
29
  it "returns an unknown code" do
@@ -30,6 +34,4 @@ describe CandyCheck::PlayStore::VerificationFailure do
30
34
  _(subject.message).must_equal "Unknown error"
31
35
  end
32
36
  end
33
-
34
- FakeError = Struct.new(:status_code, :message)
35
37
  end
@@ -32,14 +32,16 @@ describe CandyCheck::PlayStore::Verifier do
32
32
  describe "subscription purchases" do
33
33
  it "verifies a subscription purchase" do
34
34
  VCR.use_cassette("play_store/subscription_purchases/valid_but_expired") do
35
- result = subject.verify_subscription_purchase(package_name: package_name, subscription_id: subscription_id, token: token)
35
+ result = subject.verify_subscription_purchase(package_name: package_name, subscription_id: subscription_id,
36
+ token: token)
36
37
  _(result).must_be_instance_of CandyCheck::PlayStore::SubscriptionPurchases::SubscriptionPurchase
37
38
  end
38
39
  end
39
40
 
40
41
  it "can return a subscription purchase verification failure" do
41
42
  VCR.use_cassette("play_store/subscription_purchases/permission_denied") do
42
- result = subject.verify_subscription_purchase(package_name: package_name, subscription_id: subscription_id, token: token)
43
+ result = subject.verify_subscription_purchase(package_name: package_name, subscription_id: subscription_id,
44
+ token: token)
43
45
  _(result).must_be_instance_of CandyCheck::PlayStore::VerificationFailure
44
46
  end
45
47
  end
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,3 @@
1
- require "coveralls"
2
- Coveralls.wear!
3
-
4
1
  require "candy_check"
5
2
  require "candy_check/cli"
6
3
 
@@ -8,6 +5,21 @@ def in_continuous_integration_environment?
8
5
  ENV["CI"] || ENV["TRAVIS"] || ENV["CONTINUOUS_INTEGRATION"]
9
6
  end
10
7
 
8
+ require "simplecov"
9
+
10
+ SimpleCov.start do
11
+ if in_continuous_integration_environment?
12
+ require "simplecov-lcov"
13
+
14
+ SimpleCov::Formatter::LcovFormatter.config do |c|
15
+ c.report_with_single_file = true
16
+ c.single_report_path = "coverage/lcov.info"
17
+ end
18
+
19
+ formatter SimpleCov::Formatter::LcovFormatter
20
+ end
21
+ end
22
+
11
23
  require "minitest/autorun"
12
24
  require "minitest/around/spec"
13
25
  require "minitest/focus" unless in_continuous_integration_environment?
@@ -25,14 +37,13 @@ require_relative "support/with_command"
25
37
 
26
38
  ENV["DEBUG"] && Google::APIClient.logger.level = Logger::DEBUG
27
39
 
28
- class MiniTest::Spec
29
- class << self
30
- alias :context :describe
40
+ module MiniTest
41
+ class Spec
42
+ class << self
43
+ alias context describe
44
+ end
31
45
  end
32
- end
33
-
34
46
 
35
- module MiniTest
36
47
  module Assertions
37
48
  # The first parameter must be ```true```, not coercible to true.
38
49
  def assert_true(obj, msg = nil)