candy_check 0.3.0 → 0.4.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.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/candy_check.gemspec +1 -1
- data/lib/candy_check/cli/app.rb +4 -0
- data/lib/candy_check/version.rb +1 -1
- data/spec/app_store/client_spec.rb +2 -2
- data/spec/app_store/config_spec.rb +5 -5
- data/spec/app_store/receipt_collection_spec.rb +9 -9
- data/spec/app_store/receipt_spec.rb +16 -16
- data/spec/app_store/subscription_verification_spec.rb +20 -20
- data/spec/app_store/verifcation_failure_spec.rb +6 -6
- data/spec/app_store/verification_spec.rb +12 -12
- data/spec/app_store/verifier_spec.rb +14 -14
- data/spec/candy_check_spec.rb +1 -1
- data/spec/cli/app_spec.rb +10 -6
- data/spec/cli/commands/app_store_spec.rb +6 -6
- data/spec/cli/commands/version_spec.rb +1 -1
- data/spec/cli/out_spec.rb +4 -4
- data/spec/play_store/acknowledger_spec.rb +11 -11
- data/spec/play_store/product_acknowledgements/acknowledgement_spec.rb +11 -11
- data/spec/play_store/product_acknowledgements/response_spec.rb +5 -5
- data/spec/play_store/product_purchases/product_purchase_spec.rb +11 -11
- data/spec/play_store/product_purchases/product_verification_spec.rb +7 -7
- data/spec/play_store/subscription_purchases/subscription_purchase_spec.rb +25 -25
- data/spec/play_store/subscription_purchases/subscription_verification_spec.rb +7 -7
- data/spec/play_store/verification_failure_spec.rb +4 -4
- data/spec/play_store/verifier_spec.rb +6 -6
- data/spec/support/with_command.rb +0 -3
- metadata +11 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3880f9380c3e43460a14e5cdf213458159def3de2f406e3eb43c277de2504586
|
4
|
+
data.tar.gz: 3ca572324c579cf75c5c9f80d50681c1b3a374a87b2bdadb1fba9bebea659290
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ecf405edb1c05d625d3cf24f99dd5d4ab8e1dac032986a67243e40f1906eac0e45ed2cf2abc9bc23886b15fb27d003d134fa763b583826480128e81ba0eccca
|
7
|
+
data.tar.gz: 1f2eb8f806ce6fe2f07bd7326e408b1109c933cfc35e20db7acb349b1947e375caf98453c5675013a27c077db458cc832133aa9e4b7b9b54eca0dd9d88ac1976
|
data/.gitignore
CHANGED
data/candy_check.gemspec
CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
|
23
23
|
spec.add_dependency "google-api-client", "~> 0.43.0"
|
24
24
|
spec.add_dependency "multi_json", "~> 1.10"
|
25
|
-
spec.add_dependency "thor", "
|
25
|
+
spec.add_dependency "thor", "< 2.0"
|
26
26
|
|
27
27
|
spec.add_development_dependency "bundler", "~> 2.0"
|
28
28
|
spec.add_development_dependency "coveralls", "~> 0.8"
|
data/lib/candy_check/cli/app.rb
CHANGED
data/lib/candy_check/version.rb
CHANGED
@@ -39,7 +39,7 @@ describe CandyCheck::AppStore::Client do
|
|
39
39
|
body: response
|
40
40
|
)
|
41
41
|
result = subject.verify(receipt_data)
|
42
|
-
result.must_equal expected
|
42
|
+
_(result).must_equal expected
|
43
43
|
end
|
44
44
|
|
45
45
|
it 'sends JSON and parses the JSON response with a secret' do
|
@@ -54,7 +54,7 @@ describe CandyCheck::AppStore::Client do
|
|
54
54
|
body: response
|
55
55
|
)
|
56
56
|
result = subject.verify(receipt_data, password)
|
57
|
-
result.must_equal expected
|
57
|
+
_(result).must_equal expected
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
@@ -11,16 +11,16 @@ describe CandyCheck::AppStore::Config do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'returns environment' do
|
14
|
-
subject.environment.must_equal :sandbox
|
14
|
+
_(subject.environment).must_equal :sandbox
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'checks for production?' do
|
18
|
-
subject.production
|
18
|
+
_(subject.production?).must_be_false
|
19
19
|
|
20
20
|
other = CandyCheck::AppStore::Config.new(
|
21
21
|
environment: :production
|
22
22
|
)
|
23
|
-
other.production
|
23
|
+
_(other.production?).must_be_true
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -30,12 +30,12 @@ describe CandyCheck::AppStore::Config do
|
|
30
30
|
end
|
31
31
|
|
32
32
|
it 'needs an environment' do
|
33
|
-
proc { subject }.must_raise ArgumentError
|
33
|
+
_(proc { subject }).must_raise ArgumentError
|
34
34
|
end
|
35
35
|
|
36
36
|
it 'needs an included environment' do
|
37
37
|
attributes[:environment] = :invalid
|
38
|
-
proc { subject }.must_raise ArgumentError
|
38
|
+
_(proc { subject }).must_raise ArgumentError
|
39
39
|
end
|
40
40
|
end
|
41
41
|
end
|
@@ -19,27 +19,27 @@ describe CandyCheck::AppStore::ReceiptCollection do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'is expired' do
|
22
|
-
subject.expired
|
22
|
+
_(subject.expired?).must_be_true
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'is not a trial' do
|
26
|
-
subject.trial
|
26
|
+
_(subject.trial?).must_be_false
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'has positive overdue days' do
|
30
30
|
overdue = subject.overdue_days
|
31
|
-
overdue.must_be_instance_of Fixnum
|
31
|
+
_(overdue).must_be_instance_of Fixnum
|
32
32
|
assert overdue > 0
|
33
33
|
end
|
34
34
|
|
35
35
|
it 'has a last expires date' do
|
36
36
|
expected = DateTime.new(2015, 4, 15, 12, 52, 40)
|
37
|
-
subject.expires_at.must_equal expected
|
37
|
+
_(subject.expires_at).must_equal expected
|
38
38
|
end
|
39
39
|
|
40
40
|
it 'is expired? at same pointin time' do
|
41
41
|
Timecop.freeze(Time.utc(2015, 4, 15, 12, 52, 40)) do
|
42
|
-
subject.expired
|
42
|
+
_(subject.expired?).must_be_true
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
@@ -61,7 +61,7 @@ describe CandyCheck::AppStore::ReceiptCollection do
|
|
61
61
|
|
62
62
|
it 'the expires date is the latest one in time' do
|
63
63
|
expected = DateTime.new(2015, 4, 15, 12, 52, 40)
|
64
|
-
subject.expires_at.must_equal expected
|
64
|
+
_(subject.expires_at).must_equal expected
|
65
65
|
end
|
66
66
|
|
67
67
|
end
|
@@ -83,15 +83,15 @@ describe CandyCheck::AppStore::ReceiptCollection do
|
|
83
83
|
end
|
84
84
|
|
85
85
|
it 'has not expired' do
|
86
|
-
subject.expired
|
86
|
+
_(subject.expired?).must_be_false
|
87
87
|
end
|
88
88
|
|
89
89
|
it 'it is a trial' do
|
90
|
-
subject.trial
|
90
|
+
_(subject.trial?).must_be_true
|
91
91
|
end
|
92
92
|
|
93
93
|
it 'expires in two days' do
|
94
|
-
subject.overdue_days.must_equal(-2)
|
94
|
+
_(subject.overdue_days).must_equal(-2)
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
@@ -31,62 +31,62 @@ describe CandyCheck::AppStore::Receipt do
|
|
31
31
|
|
32
32
|
describe 'valid transaction' do
|
33
33
|
it 'is valid' do
|
34
|
-
subject.valid
|
34
|
+
_(subject.valid?).must_be_true
|
35
35
|
end
|
36
36
|
|
37
37
|
it 'returns the item\'s id' do
|
38
|
-
subject.item_id.must_equal 'some_item_id'
|
38
|
+
_(subject.item_id).must_equal 'some_item_id'
|
39
39
|
end
|
40
40
|
|
41
41
|
it 'returns the item\'s product_id' do
|
42
|
-
subject.product_id.must_equal 'some_product'
|
42
|
+
_(subject.product_id).must_equal 'some_product'
|
43
43
|
end
|
44
44
|
|
45
45
|
it 'returns the quantity' do
|
46
|
-
subject.quantity.must_equal 1
|
46
|
+
_(subject.quantity).must_equal 1
|
47
47
|
end
|
48
48
|
|
49
49
|
it 'returns the app version' do
|
50
|
-
subject.app_version.must_equal '2.0'
|
50
|
+
_(subject.app_version).must_equal '2.0'
|
51
51
|
end
|
52
52
|
|
53
53
|
it 'returns the bundle identifier' do
|
54
|
-
subject.bundle_identifier.must_equal 'some.test.app'
|
54
|
+
_(subject.bundle_identifier).must_equal 'some.test.app'
|
55
55
|
end
|
56
56
|
|
57
57
|
it 'returns the purchase date' do
|
58
58
|
expected = DateTime.new(2015, 1, 9, 11, 40, 46)
|
59
|
-
subject.purchase_date.must_equal expected
|
59
|
+
_(subject.purchase_date).must_equal expected
|
60
60
|
end
|
61
61
|
|
62
62
|
it 'returns the original purchase date' do
|
63
63
|
expected = DateTime.new(2015, 1, 8, 11, 40, 46)
|
64
|
-
subject.original_purchase_date.must_equal expected
|
64
|
+
_(subject.original_purchase_date).must_equal expected
|
65
65
|
end
|
66
66
|
|
67
67
|
it 'returns the transaction id' do
|
68
|
-
subject.transaction_id.must_equal 'some_transaction_id'
|
68
|
+
_(subject.transaction_id).must_equal 'some_transaction_id'
|
69
69
|
end
|
70
70
|
|
71
71
|
it 'returns the original transaction id' do
|
72
|
-
subject.original_transaction_id.must_equal 'some_original_transaction_id'
|
72
|
+
_(subject.original_transaction_id).must_equal 'some_original_transaction_id'
|
73
73
|
end
|
74
74
|
|
75
75
|
it 'return nil for cancellation date' do
|
76
|
-
subject.cancellation_date.must_be_nil
|
76
|
+
_(subject.cancellation_date).must_be_nil
|
77
77
|
end
|
78
78
|
|
79
79
|
it 'returns raw attributes' do
|
80
|
-
subject.attributes.must_be_same_as attributes
|
80
|
+
_(subject.attributes).must_be_same_as attributes
|
81
81
|
end
|
82
82
|
|
83
83
|
it 'returns the subscription expiration date' do
|
84
84
|
expected = DateTime.new(2016, 6, 9, 13, 59, 40)
|
85
|
-
subject.expires_date.must_equal expected
|
85
|
+
_(subject.expires_date).must_equal expected
|
86
86
|
end
|
87
87
|
|
88
88
|
it 'returns the trial status' do
|
89
|
-
subject.is_trial_period.must_be_false
|
89
|
+
_(subject.is_trial_period).must_be_false
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
@@ -96,12 +96,12 @@ describe CandyCheck::AppStore::Receipt do
|
|
96
96
|
end
|
97
97
|
|
98
98
|
it 'isn\'t valid' do
|
99
|
-
subject.valid
|
99
|
+
_(subject.valid?).must_be_false
|
100
100
|
end
|
101
101
|
|
102
102
|
it 'return nil for cancellation date' do
|
103
103
|
expected = DateTime.new(2015, 1, 12, 11, 40, 46)
|
104
|
-
subject.cancellation_date.must_equal expected
|
104
|
+
_(subject.cancellation_date).must_equal expected
|
105
105
|
end
|
106
106
|
end
|
107
107
|
end
|
@@ -11,26 +11,26 @@ describe CandyCheck::AppStore::SubscriptionVerification do
|
|
11
11
|
it 'returns a verification failure for status != 0' do
|
12
12
|
with_mocked_response('status' => 21_000) do |client, recorded|
|
13
13
|
result = subject.call!
|
14
|
-
client.receipt_data.must_equal data
|
15
|
-
client.secret.must_equal secret
|
14
|
+
_(client.receipt_data).must_equal data
|
15
|
+
_(client.secret).must_equal secret
|
16
16
|
|
17
|
-
recorded.first.must_equal [endpoint]
|
17
|
+
_(recorded.first).must_equal [endpoint]
|
18
18
|
|
19
|
-
result.must_be_instance_of CandyCheck::AppStore::VerificationFailure
|
20
|
-
result.code.must_equal 21_000
|
19
|
+
_(result).must_be_instance_of CandyCheck::AppStore::VerificationFailure
|
20
|
+
_(result.code).must_equal 21_000
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
24
|
it 'returns a verification failure when receipt is missing' do
|
25
25
|
with_mocked_response({}) do |client, recorded|
|
26
26
|
result = subject.call!
|
27
|
-
client.receipt_data.must_equal data
|
28
|
-
client.secret.must_equal secret
|
27
|
+
_(client.receipt_data).must_equal data
|
28
|
+
_(client.secret).must_equal secret
|
29
29
|
|
30
|
-
recorded.first.must_equal [endpoint]
|
30
|
+
_(recorded.first).must_equal [endpoint]
|
31
31
|
|
32
|
-
result.must_be_instance_of CandyCheck::AppStore::VerificationFailure
|
33
|
-
result.code.must_equal(-1)
|
32
|
+
_(result).must_be_instance_of CandyCheck::AppStore::VerificationFailure
|
33
|
+
_(result.code).must_equal(-1)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
@@ -44,12 +44,12 @@ describe CandyCheck::AppStore::SubscriptionVerification do
|
|
44
44
|
}
|
45
45
|
with_mocked_response(response) do
|
46
46
|
result = subject.call!
|
47
|
-
result.must_be_instance_of CandyCheck::AppStore::ReceiptCollection
|
48
|
-
result.receipts.must_be_instance_of Array
|
49
|
-
result.receipts.size.must_equal(2)
|
47
|
+
_(result).must_be_instance_of CandyCheck::AppStore::ReceiptCollection
|
48
|
+
_(result.receipts).must_be_instance_of Array
|
49
|
+
_(result.receipts.size).must_equal(2)
|
50
50
|
last = result.receipts.last
|
51
|
-
last.must_be_instance_of CandyCheck::AppStore::Receipt
|
52
|
-
last.item_id.must_equal('some_other_id')
|
51
|
+
_(last).must_be_instance_of CandyCheck::AppStore::Receipt
|
52
|
+
_(last.item_id).must_equal('some_other_id')
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
@@ -75,12 +75,12 @@ describe CandyCheck::AppStore::SubscriptionVerification do
|
|
75
75
|
}
|
76
76
|
with_mocked_response(response) do
|
77
77
|
result = subject.call!
|
78
|
-
result.must_be_instance_of CandyCheck::AppStore::ReceiptCollection
|
79
|
-
result.receipts.must_be_instance_of Array
|
80
|
-
result.receipts.size.must_equal(2)
|
78
|
+
_(result).must_be_instance_of CandyCheck::AppStore::ReceiptCollection
|
79
|
+
_(result.receipts).must_be_instance_of Array
|
80
|
+
_(result.receipts.size).must_equal(2)
|
81
81
|
last = result.receipts.last
|
82
|
-
last.must_be_instance_of CandyCheck::AppStore::Receipt
|
83
|
-
last.item_id.must_equal('some_other_id')
|
82
|
+
_(last).must_be_instance_of CandyCheck::AppStore::Receipt
|
83
|
+
_(last.item_id).must_equal('some_other_id')
|
84
84
|
end
|
85
85
|
end
|
86
86
|
end
|
@@ -9,20 +9,20 @@ describe CandyCheck::AppStore::VerificationFailure do
|
|
9
9
|
it 'fetched an failure with message for every known code' do
|
10
10
|
known.each do |code|
|
11
11
|
got = subject.fetch(code)
|
12
|
-
got.code.must_equal code
|
13
|
-
got.message.wont_equal 'Unknown error'
|
12
|
+
_(got.code).must_equal code
|
13
|
+
_(got.message).wont_equal 'Unknown error'
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'fetched an failure for unknown codes' do
|
18
18
|
got = subject.fetch(1234)
|
19
|
-
got.code.must_equal 1234
|
20
|
-
got.message.must_equal 'Unknown error'
|
19
|
+
_(got.code).must_equal 1234
|
20
|
+
_(got.message).must_equal 'Unknown error'
|
21
21
|
end
|
22
22
|
|
23
23
|
it 'fetched an failure for nil code' do
|
24
24
|
got = subject.fetch(nil)
|
25
|
-
got.code.must_equal(-1)
|
26
|
-
got.message.must_equal 'Unknown error'
|
25
|
+
_(got.code).must_equal(-1)
|
26
|
+
_(got.message).must_equal 'Unknown error'
|
27
27
|
end
|
28
28
|
end
|
@@ -9,26 +9,26 @@ describe CandyCheck::AppStore::Verification do
|
|
9
9
|
it 'returns a verification failure for status != 0' do
|
10
10
|
with_mocked_response('status' => 21_000) do |client, recorded|
|
11
11
|
result = subject.call!
|
12
|
-
client.receipt_data.must_equal data
|
13
|
-
client.secret.must_equal secret
|
12
|
+
_(client.receipt_data).must_equal data
|
13
|
+
_(client.secret).must_equal secret
|
14
14
|
|
15
|
-
recorded.first.must_equal [endpoint]
|
15
|
+
_(recorded.first).must_equal [endpoint]
|
16
16
|
|
17
|
-
result.must_be_instance_of CandyCheck::AppStore::VerificationFailure
|
18
|
-
result.code.must_equal 21_000
|
17
|
+
_(result).must_be_instance_of CandyCheck::AppStore::VerificationFailure
|
18
|
+
_(result.code).must_equal 21_000
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
22
|
it 'returns a verification failure when receipt is missing' do
|
23
23
|
with_mocked_response({}) do |client, recorded|
|
24
24
|
result = subject.call!
|
25
|
-
client.receipt_data.must_equal data
|
26
|
-
client.secret.must_equal secret
|
25
|
+
_(client.receipt_data).must_equal data
|
26
|
+
_(client.secret).must_equal secret
|
27
27
|
|
28
|
-
recorded.first.must_equal [endpoint]
|
28
|
+
_(recorded.first).must_equal [endpoint]
|
29
29
|
|
30
|
-
result.must_be_instance_of CandyCheck::AppStore::VerificationFailure
|
31
|
-
result.code.must_equal(-1)
|
30
|
+
_(result).must_be_instance_of CandyCheck::AppStore::VerificationFailure
|
31
|
+
_(result.code).must_equal(-1)
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
@@ -36,8 +36,8 @@ describe CandyCheck::AppStore::Verification do
|
|
36
36
|
response = { 'status' => 0, 'receipt' => { 'item_id' => 'some_id' } }
|
37
37
|
with_mocked_response(response) do
|
38
38
|
result = subject.call!
|
39
|
-
result.must_be_instance_of CandyCheck::AppStore::Receipt
|
40
|
-
result.item_id.must_equal('some_id')
|
39
|
+
_(result).must_be_instance_of CandyCheck::AppStore::Receipt
|
40
|
+
_(result.item_id).must_equal('some_id')
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
@@ -18,7 +18,7 @@ describe CandyCheck::AppStore::Verifier do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'holds the config' do
|
21
|
-
subject.config.must_be_same_as config
|
21
|
+
_(subject.config).must_be_same_as config
|
22
22
|
end
|
23
23
|
|
24
24
|
describe 'sandbox' do
|
@@ -26,7 +26,7 @@ describe CandyCheck::AppStore::Verifier do
|
|
26
26
|
|
27
27
|
it 'uses sandbox endpoint without retry on success' do
|
28
28
|
with_mocked_verifier(receipt) do
|
29
|
-
subject.verify(data, secret).must_be_same_as receipt
|
29
|
+
_(subject.verify(data, secret)).must_be_same_as receipt
|
30
30
|
assert_recorded([sandbox_endpoint, data, secret])
|
31
31
|
end
|
32
32
|
end
|
@@ -34,7 +34,7 @@ describe CandyCheck::AppStore::Verifier do
|
|
34
34
|
it 'only uses sandbox endpoint for normal failures' do
|
35
35
|
failure = get_failure(21_000)
|
36
36
|
with_mocked_verifier(failure) do
|
37
|
-
subject.verify(data, secret).must_be_same_as failure
|
37
|
+
_(subject.verify(data, secret)).must_be_same_as failure
|
38
38
|
assert_recorded([sandbox_endpoint, data, secret])
|
39
39
|
end
|
40
40
|
end
|
@@ -42,7 +42,7 @@ describe CandyCheck::AppStore::Verifier do
|
|
42
42
|
it 'retries production endpoint for redirect error' do
|
43
43
|
failure = get_failure(21_008)
|
44
44
|
with_mocked_verifier(failure, receipt) do
|
45
|
-
subject.verify(data, secret).must_be_same_as receipt
|
45
|
+
_(subject.verify(data, secret)).must_be_same_as receipt
|
46
46
|
assert_recorded(
|
47
47
|
[sandbox_endpoint, data, secret],
|
48
48
|
[production_endpoint, data, secret]
|
@@ -56,7 +56,7 @@ describe CandyCheck::AppStore::Verifier do
|
|
56
56
|
|
57
57
|
it 'uses production endpoint without retry on success' do
|
58
58
|
with_mocked_verifier(receipt) do
|
59
|
-
subject.verify(data, secret).must_be_same_as receipt
|
59
|
+
_(subject.verify(data, secret)).must_be_same_as receipt
|
60
60
|
assert_recorded([production_endpoint, data, secret])
|
61
61
|
end
|
62
62
|
end
|
@@ -64,7 +64,7 @@ describe CandyCheck::AppStore::Verifier do
|
|
64
64
|
it 'only uses production endpoint for normal failures' do
|
65
65
|
failure = get_failure(21_000)
|
66
66
|
with_mocked_verifier(failure) do
|
67
|
-
subject.verify(data, secret).must_be_same_as failure
|
67
|
+
_(subject.verify(data, secret)).must_be_same_as failure
|
68
68
|
assert_recorded([production_endpoint, data, secret])
|
69
69
|
end
|
70
70
|
end
|
@@ -72,7 +72,7 @@ describe CandyCheck::AppStore::Verifier do
|
|
72
72
|
it 'retries production endpoint for redirect error' do
|
73
73
|
failure = get_failure(21_007)
|
74
74
|
with_mocked_verifier(failure, receipt) do
|
75
|
-
subject.verify(data, secret).must_be_same_as receipt
|
75
|
+
_(subject.verify(data, secret)).must_be_same_as receipt
|
76
76
|
assert_recorded(
|
77
77
|
[production_endpoint, data, secret],
|
78
78
|
[sandbox_endpoint, data, secret]
|
@@ -86,9 +86,9 @@ describe CandyCheck::AppStore::Verifier do
|
|
86
86
|
|
87
87
|
it 'uses production endpoint without retry on success' do
|
88
88
|
with_mocked_verifier(receipt_collection) do
|
89
|
-
subject.verify_subscription(
|
89
|
+
_(subject.verify_subscription(
|
90
90
|
data, secret
|
91
|
-
).must_be_same_as receipt_collection
|
91
|
+
)).must_be_same_as receipt_collection
|
92
92
|
assert_recorded([production_endpoint, data, secret, nil])
|
93
93
|
end
|
94
94
|
end
|
@@ -96,7 +96,7 @@ describe CandyCheck::AppStore::Verifier do
|
|
96
96
|
it 'only uses production endpoint for normal failures' do
|
97
97
|
failure = get_failure(21_000)
|
98
98
|
with_mocked_verifier(failure) do
|
99
|
-
subject.verify_subscription(data, secret).must_be_same_as failure
|
99
|
+
_(subject.verify_subscription(data, secret)).must_be_same_as failure
|
100
100
|
assert_recorded([production_endpoint, data, secret, nil])
|
101
101
|
end
|
102
102
|
end
|
@@ -104,7 +104,7 @@ describe CandyCheck::AppStore::Verifier do
|
|
104
104
|
it 'retries production endpoint for redirect error' do
|
105
105
|
failure = get_failure(21_007)
|
106
106
|
with_mocked_verifier(failure, receipt) do
|
107
|
-
subject.verify_subscription(data, secret).must_be_same_as receipt
|
107
|
+
_(subject.verify_subscription(data, secret)).must_be_same_as receipt
|
108
108
|
assert_recorded(
|
109
109
|
[production_endpoint, data, secret, nil],
|
110
110
|
[sandbox_endpoint, data, secret, nil]
|
@@ -115,9 +115,9 @@ describe CandyCheck::AppStore::Verifier do
|
|
115
115
|
it 'passed the product_ids' do
|
116
116
|
product_ids = ['product_1']
|
117
117
|
with_mocked_verifier(receipt_collection) do
|
118
|
-
subject.verify_subscription(
|
118
|
+
_(subject.verify_subscription(
|
119
119
|
data, secret, product_ids
|
120
|
-
).must_be_same_as receipt_collection
|
120
|
+
)).must_be_same_as receipt_collection
|
121
121
|
assert_recorded([production_endpoint, data, secret, product_ids])
|
122
122
|
end
|
123
123
|
end
|
@@ -137,7 +137,7 @@ describe CandyCheck::AppStore::Verifier do
|
|
137
137
|
end
|
138
138
|
|
139
139
|
def assert_recorded(*calls)
|
140
|
-
@recorded.must_equal calls
|
140
|
+
_(@recorded).must_equal calls
|
141
141
|
end
|
142
142
|
|
143
143
|
def get_failure(code)
|
data/spec/candy_check_spec.rb
CHANGED
data/spec/cli/app_spec.rb
CHANGED
@@ -5,25 +5,29 @@ describe CandyCheck::CLI::App do
|
|
5
5
|
|
6
6
|
it 'supports the version command' do
|
7
7
|
stub_command(CandyCheck::CLI::Commands::Version) do
|
8
|
-
subject.version.must_equal :stubbed
|
9
|
-
@arguments.must_be_empty
|
8
|
+
_(subject.version).must_equal :stubbed
|
9
|
+
_(@arguments).must_be_empty
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'supports the app_store command' do
|
14
14
|
stub_command(CandyCheck::CLI::Commands::AppStore) do
|
15
|
-
subject.app_store('receipt').must_equal :stubbed
|
16
|
-
@arguments.must_equal ['receipt', {}]
|
15
|
+
_(subject.app_store('receipt')).must_equal :stubbed
|
16
|
+
_(@arguments).must_equal ['receipt', {}]
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'supports the play_store command' do
|
21
21
|
stub_command(CandyCheck::CLI::Commands::PlayStore) do
|
22
|
-
subject.play_store('package', 'id', 'token').must_equal :stubbed
|
23
|
-
@arguments.must_equal ['package', 'id', 'token', {}]
|
22
|
+
_(subject.play_store('package', 'id', 'token')).must_equal :stubbed
|
23
|
+
_(@arguments).must_equal ['package', 'id', 'token', {}]
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
+
it 'returns true when call .exit_on_failure?' do
|
28
|
+
_(CandyCheck::CLI::App.exit_on_failure?).must_equal true
|
29
|
+
end
|
30
|
+
|
27
31
|
private
|
28
32
|
|
29
33
|
def stub_command(target)
|
@@ -22,9 +22,9 @@ describe CandyCheck::CLI::Commands::AppStore do
|
|
22
22
|
|
23
23
|
describe 'default' do
|
24
24
|
it 'uses the receipt and the options' do
|
25
|
-
@verifier.config.environment.must_equal :sandbox
|
26
|
-
@verifier.arguments.must_equal [receipt, nil]
|
27
|
-
out.
|
25
|
+
_(@verifier.config.environment).must_equal :sandbox
|
26
|
+
_(@verifier.arguments).must_equal [receipt, nil]
|
27
|
+
_(out.lines).must_equal ['Hash:', { result: :stubbed }]
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
@@ -37,9 +37,9 @@ describe CandyCheck::CLI::Commands::AppStore do
|
|
37
37
|
end
|
38
38
|
|
39
39
|
it 'uses the secret for verification' do
|
40
|
-
@verifier.config.environment.must_equal :production
|
41
|
-
@verifier.arguments.must_equal [receipt, 'notasecret']
|
42
|
-
out.
|
40
|
+
_(@verifier.config.environment).must_equal :production
|
41
|
+
_(@verifier.arguments).must_equal [receipt, 'notasecret']
|
42
|
+
_(out.lines).must_equal ['Hash:', { result: :stubbed }]
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
data/spec/cli/out_spec.rb
CHANGED
@@ -5,18 +5,18 @@ describe CandyCheck::CLI::Out do
|
|
5
5
|
let(:out) { StringIO.new }
|
6
6
|
|
7
7
|
it 'defaults to use STDOUT' do
|
8
|
-
CandyCheck::CLI::Out.new.out.must_be_same_as $stdout
|
8
|
+
_(CandyCheck::CLI::Out.new.out).must_be_same_as $stdout
|
9
9
|
end
|
10
10
|
|
11
11
|
it 'holds the outlet' do
|
12
|
-
subject.out.must_be_same_as out
|
12
|
+
_(subject.out).must_be_same_as out
|
13
13
|
end
|
14
14
|
|
15
15
|
it 'prints to outlet' do
|
16
16
|
subject.print 'some text'
|
17
17
|
subject.print 'another line'
|
18
18
|
close
|
19
|
-
out.readlines.must_equal [
|
19
|
+
_(out.readlines).must_equal [
|
20
20
|
"some text\n",
|
21
21
|
"another line\n"
|
22
22
|
]
|
@@ -26,7 +26,7 @@ describe CandyCheck::CLI::Out do
|
|
26
26
|
subject.pretty dummy: 1
|
27
27
|
subject.pretty [1, 2, 3]
|
28
28
|
close
|
29
|
-
out.readlines.must_equal [
|
29
|
+
_(out.readlines).must_equal [
|
30
30
|
"{:dummy=>1}\n",
|
31
31
|
"[1, 2, 3]\n"
|
32
32
|
]
|
@@ -15,9 +15,9 @@ describe CandyCheck::PlayStore::Acknowledger do
|
|
15
15
|
VCR.use_cassette("play_store/product_acknowledgements/acknowledged") do
|
16
16
|
result = subject.acknowledge_product_purchase(package_name: package_name, product_id: product_id, token: token)
|
17
17
|
|
18
|
-
result.must_be_instance_of CandyCheck::PlayStore::ProductAcknowledgements::Response
|
19
|
-
result.acknowledged
|
20
|
-
result.error.must_be_nil
|
18
|
+
_(result).must_be_instance_of CandyCheck::PlayStore::ProductAcknowledgements::Response
|
19
|
+
_(result.acknowledged?).must_be_true
|
20
|
+
_(result.error).must_be_nil
|
21
21
|
end
|
22
22
|
end
|
23
23
|
it "when already acknowledged" do
|
@@ -26,10 +26,10 @@ describe CandyCheck::PlayStore::Acknowledger do
|
|
26
26
|
VCR.use_cassette("play_store/product_acknowledgements/already_acknowledged") do
|
27
27
|
result = subject.acknowledge_product_purchase(package_name: package_name, product_id: product_id, token: token)
|
28
28
|
|
29
|
-
result.must_be_instance_of CandyCheck::PlayStore::ProductAcknowledgements::Response
|
30
|
-
result.acknowledged
|
31
|
-
result.error[:body].must_equal(error_body)
|
32
|
-
result.error[:status_code].must_equal(400)
|
29
|
+
_(result).must_be_instance_of CandyCheck::PlayStore::ProductAcknowledgements::Response
|
30
|
+
_(result.acknowledged?).must_be_false
|
31
|
+
_(result.error[:body]).must_equal(error_body)
|
32
|
+
_(result.error[:status_code]).must_equal(400)
|
33
33
|
end
|
34
34
|
end
|
35
35
|
it "when it has been refunded" do
|
@@ -38,10 +38,10 @@ describe CandyCheck::PlayStore::Acknowledger do
|
|
38
38
|
VCR.use_cassette("play_store/product_acknowledgements/refunded") do
|
39
39
|
result = subject.acknowledge_product_purchase(package_name: package_name, product_id: product_id, token: token)
|
40
40
|
|
41
|
-
result.must_be_instance_of CandyCheck::PlayStore::ProductAcknowledgements::Response
|
42
|
-
result.acknowledged
|
43
|
-
result.error[:body].must_equal(error_body)
|
44
|
-
result.error[:status_code].must_equal(400)
|
41
|
+
_(result).must_be_instance_of CandyCheck::PlayStore::ProductAcknowledgements::Response
|
42
|
+
_(result.acknowledged?).must_be_false
|
43
|
+
_(result.error[:body]).must_equal(error_body)
|
44
|
+
_(result.error[:status_code]).must_equal(400)
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
@@ -21,9 +21,9 @@ describe CandyCheck::PlayStore::ProductAcknowledgements::Acknowledgement do
|
|
21
21
|
VCR.use_cassette("play_store/product_acknowledgements/acknowledged") do
|
22
22
|
result = subject.call!
|
23
23
|
|
24
|
-
result.must_be_instance_of CandyCheck::PlayStore::ProductAcknowledgements::Response
|
25
|
-
result.acknowledged
|
26
|
-
result.error.must_be_nil
|
24
|
+
_(result).must_be_instance_of CandyCheck::PlayStore::ProductAcknowledgements::Response
|
25
|
+
_(result.acknowledged?).must_be_true
|
26
|
+
_(result.error).must_be_nil
|
27
27
|
end
|
28
28
|
end
|
29
29
|
it "when already acknowledged" do
|
@@ -32,10 +32,10 @@ describe CandyCheck::PlayStore::ProductAcknowledgements::Acknowledgement do
|
|
32
32
|
VCR.use_cassette("play_store/product_acknowledgements/already_acknowledged") do
|
33
33
|
result = subject.call!
|
34
34
|
|
35
|
-
result.must_be_instance_of CandyCheck::PlayStore::ProductAcknowledgements::Response
|
36
|
-
result.acknowledged
|
37
|
-
result.error[:body].must_equal(error_body)
|
38
|
-
result.error[:status_code].must_equal(400)
|
35
|
+
_(result).must_be_instance_of CandyCheck::PlayStore::ProductAcknowledgements::Response
|
36
|
+
_(result.acknowledged?).must_be_false
|
37
|
+
_(result.error[:body]).must_equal(error_body)
|
38
|
+
_(result.error[:status_code]).must_equal(400)
|
39
39
|
end
|
40
40
|
end
|
41
41
|
it "when it has been refunded" do
|
@@ -44,10 +44,10 @@ describe CandyCheck::PlayStore::ProductAcknowledgements::Acknowledgement do
|
|
44
44
|
VCR.use_cassette("play_store/product_acknowledgements/refunded") do
|
45
45
|
result = subject.call!
|
46
46
|
|
47
|
-
result.must_be_instance_of CandyCheck::PlayStore::ProductAcknowledgements::Response
|
48
|
-
result.acknowledged
|
49
|
-
result.error[:body].must_equal(error_body)
|
50
|
-
result.error[:status_code].must_equal(400)
|
47
|
+
_(result).must_be_instance_of CandyCheck::PlayStore::ProductAcknowledgements::Response
|
48
|
+
_(result.acknowledged?).must_be_false
|
49
|
+
_(result.error[:body]).must_equal(error_body)
|
50
|
+
_(result.error[:status_code]).must_equal(400)
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|
@@ -13,7 +13,7 @@ describe CandyCheck::PlayStore::ProductAcknowledgements::Response do
|
|
13
13
|
it 'returns true' do
|
14
14
|
result = subject.acknowledged?
|
15
15
|
|
16
|
-
result.must_be_true
|
16
|
+
_(result).must_be_true
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -24,7 +24,7 @@ describe CandyCheck::PlayStore::ProductAcknowledgements::Response do
|
|
24
24
|
it 'returns false' do
|
25
25
|
result = subject.acknowledged?
|
26
26
|
|
27
|
-
result.must_be_false
|
27
|
+
_(result).must_be_false
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
@@ -47,8 +47,8 @@ describe CandyCheck::PlayStore::ProductAcknowledgements::Response do
|
|
47
47
|
it 'returns the expected data' do
|
48
48
|
result = subject.error
|
49
49
|
|
50
|
-
result[:status_code].must_equal(400)
|
51
|
-
result[:body].must_equal('A String describing the issue')
|
50
|
+
_(result[:status_code]).must_equal(400)
|
51
|
+
_(result[:body]).must_equal('A String describing the issue')
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
@@ -59,7 +59,7 @@ describe CandyCheck::PlayStore::ProductAcknowledgements::Response do
|
|
59
59
|
it 'returns false' do
|
60
60
|
result = subject.error
|
61
61
|
|
62
|
-
result.must_be_nil
|
62
|
+
_(result).must_be_nil
|
63
63
|
end
|
64
64
|
end
|
65
65
|
end
|
@@ -16,36 +16,36 @@ describe CandyCheck::PlayStore::ProductPurchases::ProductPurchase do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
it "is valid?" do
|
19
|
-
subject.valid
|
19
|
+
_(subject.valid?).must_be_true
|
20
20
|
end
|
21
21
|
|
22
22
|
it "is not consumed" do
|
23
|
-
subject.consumed
|
23
|
+
_(subject.consumed?).must_be_false
|
24
24
|
end
|
25
25
|
|
26
26
|
it "returns the purchase_state" do
|
27
|
-
subject.purchase_state.must_equal 0
|
27
|
+
_(subject.purchase_state).must_equal 0
|
28
28
|
end
|
29
29
|
|
30
30
|
it "returns the consumption_state" do
|
31
|
-
subject.consumption_state.must_equal 0
|
31
|
+
_(subject.consumption_state).must_equal 0
|
32
32
|
end
|
33
33
|
|
34
34
|
it "returns the developer_payload" do
|
35
|
-
subject.developer_payload.must_equal "payload that gets stored and returned"
|
35
|
+
_(subject.developer_payload).must_equal "payload that gets stored and returned"
|
36
36
|
end
|
37
37
|
|
38
38
|
it "returns the kind" do
|
39
|
-
subject.kind.must_equal "androidpublisher#productPurchase"
|
39
|
+
_(subject.kind).must_equal "androidpublisher#productPurchase"
|
40
40
|
end
|
41
41
|
|
42
42
|
it "returns the purchase_time_millis" do
|
43
|
-
subject.purchase_time_millis.must_equal 1_421_676_237_413
|
43
|
+
_(subject.purchase_time_millis).must_equal 1_421_676_237_413
|
44
44
|
end
|
45
45
|
|
46
46
|
it "returns the purchased_at" do
|
47
47
|
expected = DateTime.new(2015, 1, 19, 14, 3, 57)
|
48
|
-
subject.purchased_at.must_equal expected
|
48
|
+
_(subject.purchased_at).must_equal expected
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
@@ -62,11 +62,11 @@ describe CandyCheck::PlayStore::ProductPurchases::ProductPurchase do
|
|
62
62
|
end
|
63
63
|
|
64
64
|
it "is valid?" do
|
65
|
-
subject.valid
|
65
|
+
_(subject.valid?).must_be_true
|
66
66
|
end
|
67
67
|
|
68
68
|
it "is consumed?" do
|
69
|
-
subject.consumed
|
69
|
+
_(subject.consumed?).must_be_true
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
@@ -83,7 +83,7 @@ describe CandyCheck::PlayStore::ProductPurchases::ProductPurchase do
|
|
83
83
|
end
|
84
84
|
|
85
85
|
it "is valid?" do
|
86
|
-
subject.valid
|
86
|
+
_(subject.valid?).must_be_false
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
@@ -20,9 +20,9 @@ describe CandyCheck::PlayStore::ProductPurchases::ProductVerification do
|
|
20
20
|
it "returns a product purchase" do
|
21
21
|
VCR.use_cassette("play_store/product_purchases/valid_but_not_consumed") do
|
22
22
|
result = subject.call!
|
23
|
-
result.must_be_instance_of CandyCheck::PlayStore::ProductPurchases::ProductPurchase
|
24
|
-
result.valid
|
25
|
-
result.consumed
|
23
|
+
_(result).must_be_instance_of CandyCheck::PlayStore::ProductPurchases::ProductPurchase
|
24
|
+
_(result.valid?).must_be_true
|
25
|
+
_(result.consumed?).must_be_false
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
@@ -31,8 +31,8 @@ describe CandyCheck::PlayStore::ProductPurchases::ProductVerification do
|
|
31
31
|
it "returns a verification failure" do
|
32
32
|
VCR.use_cassette("play_store/product_purchases/permission_denied") do
|
33
33
|
result = subject.call!
|
34
|
-
result.must_be_instance_of CandyCheck::PlayStore::VerificationFailure
|
35
|
-
result.code.must_equal 401
|
34
|
+
_(result).must_be_instance_of CandyCheck::PlayStore::VerificationFailure
|
35
|
+
_(result.code).must_equal 401
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
@@ -41,8 +41,8 @@ describe CandyCheck::PlayStore::ProductPurchases::ProductVerification do
|
|
41
41
|
it "returns a verification failure" do
|
42
42
|
VCR.use_cassette("play_store/product_purchases/response_with_empty_body") do
|
43
43
|
result = subject.call!
|
44
|
-
result.must_be_instance_of CandyCheck::PlayStore::VerificationFailure
|
45
|
-
result.code.must_equal(-1)
|
44
|
+
_(result).must_be_instance_of CandyCheck::PlayStore::VerificationFailure
|
45
|
+
_(result.code).must_equal(-1)
|
46
46
|
end
|
47
47
|
end
|
48
48
|
end
|
@@ -17,50 +17,50 @@ describe CandyCheck::PlayStore::SubscriptionPurchases::SubscriptionPurchase do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
it "is expired?" do
|
20
|
-
subject.expired
|
20
|
+
_(subject.expired?).must_be_true
|
21
21
|
end
|
22
22
|
|
23
23
|
it "is canceled by user" do
|
24
|
-
subject.canceled_by_user
|
24
|
+
_(subject.canceled_by_user?).must_be_true
|
25
25
|
end
|
26
26
|
|
27
27
|
it "returns the payment_state" do
|
28
|
-
subject.payment_state.must_equal 1
|
28
|
+
_(subject.payment_state).must_equal 1
|
29
29
|
end
|
30
30
|
|
31
31
|
it "considers a payment as valid" do
|
32
|
-
subject.payment_received
|
32
|
+
_(subject.payment_received?).must_be_true
|
33
33
|
end
|
34
34
|
|
35
35
|
it "checks that auto renewal status is false" do
|
36
|
-
subject.auto_renewing
|
36
|
+
_(subject.auto_renewing?).must_be_false
|
37
37
|
end
|
38
38
|
|
39
39
|
it "returns the developer_payload" do
|
40
|
-
subject.developer_payload.must_equal \
|
40
|
+
_(subject.developer_payload).must_equal \
|
41
41
|
"payload that gets stored and returned"
|
42
42
|
end
|
43
43
|
|
44
44
|
it "returns the kind" do
|
45
|
-
subject.kind.must_equal "androidpublisher#subscriptionPurchase"
|
45
|
+
_(subject.kind).must_equal "androidpublisher#subscriptionPurchase"
|
46
46
|
end
|
47
47
|
|
48
48
|
it "returns the start_time_millis" do
|
49
|
-
subject.start_time_millis.must_equal 145_954_011_324_4
|
49
|
+
_(subject.start_time_millis).must_equal 145_954_011_324_4
|
50
50
|
end
|
51
51
|
|
52
52
|
it "returns the expiry_time_millis" do
|
53
|
-
subject.expiry_time_millis.must_equal 146_213_208_861_0
|
53
|
+
_(subject.expiry_time_millis).must_equal 146_213_208_861_0
|
54
54
|
end
|
55
55
|
|
56
56
|
it "returns the starts_at" do
|
57
57
|
expected = DateTime.new(2016, 4, 1, 19, 48, 33)
|
58
|
-
subject.starts_at.must_equal expected
|
58
|
+
_(subject.starts_at).must_equal expected
|
59
59
|
end
|
60
60
|
|
61
61
|
it "returns the expires_at" do
|
62
62
|
expected = DateTime.new(2016, 5, 1, 19, 48, 8)
|
63
|
-
subject.expires_at.must_equal expected
|
63
|
+
_(subject.expires_at).must_equal expected
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
@@ -79,11 +79,11 @@ describe CandyCheck::PlayStore::SubscriptionPurchases::SubscriptionPurchase do
|
|
79
79
|
end
|
80
80
|
|
81
81
|
it "is expired?" do
|
82
|
-
subject.expired
|
82
|
+
_(subject.expired?).must_be_false
|
83
83
|
end
|
84
84
|
|
85
85
|
it "is two days left until it is overdue" do
|
86
|
-
subject.overdue_days.must_equal(-2)
|
86
|
+
_(subject.overdue_days).must_equal(-2)
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
@@ -101,11 +101,11 @@ describe CandyCheck::PlayStore::SubscriptionPurchases::SubscriptionPurchase do
|
|
101
101
|
end
|
102
102
|
|
103
103
|
it "is expired?" do
|
104
|
-
subject.expired
|
104
|
+
_(subject.expired?).must_be_true
|
105
105
|
end
|
106
106
|
|
107
107
|
it "is payment_failed?" do
|
108
|
-
subject.payment_failed
|
108
|
+
_(subject.payment_failed?).must_be_true
|
109
109
|
end
|
110
110
|
end
|
111
111
|
|
@@ -123,15 +123,15 @@ describe CandyCheck::PlayStore::SubscriptionPurchases::SubscriptionPurchase do
|
|
123
123
|
end
|
124
124
|
|
125
125
|
it "is not canceled?" do
|
126
|
-
subject.canceled_by_user
|
126
|
+
_(subject.canceled_by_user?).must_be_false
|
127
127
|
end
|
128
128
|
|
129
129
|
it "returns nil user_cancellation_time_millis" do
|
130
|
-
subject.user_cancellation_time_millis.must_be_nil
|
130
|
+
_(subject.user_cancellation_time_millis).must_be_nil
|
131
131
|
end
|
132
132
|
|
133
133
|
it "returns nil canceled_at" do
|
134
|
-
subject.canceled_at.must_be_nil
|
134
|
+
_(subject.canceled_at).must_be_nil
|
135
135
|
end
|
136
136
|
end
|
137
137
|
|
@@ -150,16 +150,16 @@ describe CandyCheck::PlayStore::SubscriptionPurchases::SubscriptionPurchase do
|
|
150
150
|
end
|
151
151
|
|
152
152
|
it "is canceled?" do
|
153
|
-
subject.canceled_by_user
|
153
|
+
_(subject.canceled_by_user?).must_be_true
|
154
154
|
end
|
155
155
|
|
156
156
|
it "returns the user_cancellation_time_millis" do
|
157
|
-
subject.user_cancellation_time_millis.must_equal 1_461_872_888_000
|
157
|
+
_(subject.user_cancellation_time_millis).must_equal 1_461_872_888_000
|
158
158
|
end
|
159
159
|
|
160
160
|
it "returns the starts_at" do
|
161
161
|
expected = DateTime.new(2016, 4, 28, 19, 48, 8)
|
162
|
-
subject.canceled_at.must_equal expected
|
162
|
+
_(subject.canceled_at).must_equal expected
|
163
163
|
end
|
164
164
|
end
|
165
165
|
end
|
@@ -178,11 +178,11 @@ describe CandyCheck::PlayStore::SubscriptionPurchases::SubscriptionPurchase do
|
|
178
178
|
end
|
179
179
|
|
180
180
|
it "is expired?" do
|
181
|
-
subject.expired
|
181
|
+
_(subject.expired?).must_be_true
|
182
182
|
end
|
183
183
|
|
184
184
|
it "is payment_pending?" do
|
185
|
-
subject.payment_pending
|
185
|
+
_(subject.payment_pending?).must_be_true
|
186
186
|
end
|
187
187
|
end
|
188
188
|
|
@@ -202,11 +202,11 @@ describe CandyCheck::PlayStore::SubscriptionPurchases::SubscriptionPurchase do
|
|
202
202
|
end
|
203
203
|
|
204
204
|
it "is trial?" do
|
205
|
-
subject.trial
|
205
|
+
_(subject.trial?).must_be_true
|
206
206
|
end
|
207
207
|
|
208
208
|
it "returns the price_currency_code" do
|
209
|
-
subject.price_currency_code.must_equal "SOMECODE"
|
209
|
+
_(subject.price_currency_code).must_equal "SOMECODE"
|
210
210
|
end
|
211
211
|
end
|
212
212
|
|
@@ -22,8 +22,8 @@ describe CandyCheck::PlayStore::SubscriptionPurchases::SubscriptionVerification
|
|
22
22
|
VCR.use_cassette("play_store/subscription_purchases/valid_but_expired") do
|
23
23
|
result = subject.call!
|
24
24
|
|
25
|
-
result.must_be_instance_of CandyCheck::PlayStore::SubscriptionPurchases::SubscriptionPurchase
|
26
|
-
result.expired
|
25
|
+
_(result).must_be_instance_of CandyCheck::PlayStore::SubscriptionPurchases::SubscriptionPurchase
|
26
|
+
_(result.expired?).must_be_true
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
@@ -32,8 +32,8 @@ describe CandyCheck::PlayStore::SubscriptionPurchases::SubscriptionVerification
|
|
32
32
|
it "returns a verification failure" do
|
33
33
|
VCR.use_cassette("play_store/subscription_purchases/permission_denied") do
|
34
34
|
result = subject.call!
|
35
|
-
result.must_be_instance_of CandyCheck::PlayStore::VerificationFailure
|
36
|
-
result.code.must_equal 401
|
35
|
+
_(result).must_be_instance_of CandyCheck::PlayStore::VerificationFailure
|
36
|
+
_(result.code).must_equal 401
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
@@ -45,8 +45,8 @@ describe CandyCheck::PlayStore::SubscriptionPurchases::SubscriptionVerification
|
|
45
45
|
|
46
46
|
it "returns a verification failure" do
|
47
47
|
result = subject.call!
|
48
|
-
result.must_be_instance_of CandyCheck::PlayStore::VerificationFailure
|
49
|
-
result.code.must_equal(-1)
|
48
|
+
_(result).must_be_instance_of CandyCheck::PlayStore::VerificationFailure
|
49
|
+
_(result.code).must_equal(-1)
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
@@ -59,7 +59,7 @@ describe CandyCheck::PlayStore::SubscriptionPurchases::SubscriptionVerification
|
|
59
59
|
|
60
60
|
it "returns a verification failure" do
|
61
61
|
result = subject.call!
|
62
|
-
result.must_be_instance_of CandyCheck::PlayStore::VerificationFailure
|
62
|
+
_(result).must_be_instance_of CandyCheck::PlayStore::VerificationFailure
|
63
63
|
end
|
64
64
|
end
|
65
65
|
end
|
@@ -9,11 +9,11 @@ describe CandyCheck::PlayStore::VerificationFailure do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
it "returns the code" do
|
12
|
-
subject.code.must_equal 401
|
12
|
+
_(subject.code).must_equal 401
|
13
13
|
end
|
14
14
|
|
15
15
|
it "returns the message" do
|
16
|
-
subject.message.must_equal "The current user has insufficient permissions"
|
16
|
+
_(subject.message).must_equal "The current user has insufficient permissions"
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -23,11 +23,11 @@ describe CandyCheck::PlayStore::VerificationFailure do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
it "returns an unknown code" do
|
26
|
-
subject.code.must_equal(-1)
|
26
|
+
_(subject.code).must_equal(-1)
|
27
27
|
end
|
28
28
|
|
29
29
|
it "returns an unknown message" do
|
30
|
-
subject.message.must_equal "Unknown error"
|
30
|
+
_(subject.message).must_equal "Unknown error"
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
@@ -15,16 +15,16 @@ describe CandyCheck::PlayStore::Verifier do
|
|
15
15
|
it "verifies a product purchase" do
|
16
16
|
VCR.use_cassette("play_store/product_purchases/valid_but_not_consumed") do
|
17
17
|
result = subject.verify_product_purchase(package_name: package_name, product_id: product_id, token: token)
|
18
|
-
result.must_be_instance_of CandyCheck::PlayStore::ProductPurchases::ProductPurchase
|
19
|
-
result.valid
|
20
|
-
result.consumed
|
18
|
+
_(result).must_be_instance_of CandyCheck::PlayStore::ProductPurchases::ProductPurchase
|
19
|
+
_(result.valid?).must_be_true
|
20
|
+
_(result.consumed?).must_be_false
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
24
|
it "can return a product purchase verification failure" do
|
25
25
|
VCR.use_cassette("play_store/product_purchases/permission_denied") do
|
26
26
|
result = subject.verify_product_purchase(package_name: package_name, product_id: product_id, token: token)
|
27
|
-
result.must_be_instance_of CandyCheck::PlayStore::VerificationFailure
|
27
|
+
_(result).must_be_instance_of CandyCheck::PlayStore::VerificationFailure
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
@@ -33,14 +33,14 @@ describe CandyCheck::PlayStore::Verifier do
|
|
33
33
|
it "verifies a subscription purchase" do
|
34
34
|
VCR.use_cassette("play_store/subscription_purchases/valid_but_expired") do
|
35
35
|
result = subject.verify_subscription_purchase(package_name: package_name, subscription_id: subscription_id, token: token)
|
36
|
-
result.must_be_instance_of CandyCheck::PlayStore::SubscriptionPurchases::SubscriptionPurchase
|
36
|
+
_(result).must_be_instance_of CandyCheck::PlayStore::SubscriptionPurchases::SubscriptionPurchase
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
40
|
it "can return a subscription purchase verification failure" do
|
41
41
|
VCR.use_cassette("play_store/subscription_purchases/permission_denied") do
|
42
42
|
result = subject.verify_subscription_purchase(package_name: package_name, subscription_id: subscription_id, token: token)
|
43
|
-
result.must_be_instance_of CandyCheck::PlayStore::VerificationFailure
|
43
|
+
_(result).must_be_instance_of CandyCheck::PlayStore::VerificationFailure
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: candy_check
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonas Thiel
|
8
8
|
- Christoph Weegen
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-01-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: google-api-client
|
@@ -43,16 +43,16 @@ dependencies:
|
|
43
43
|
name: thor
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- - "
|
46
|
+
- - "<"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: '0
|
48
|
+
version: '2.0'
|
49
49
|
type: :runtime
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- - "
|
53
|
+
- - "<"
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: '0
|
55
|
+
version: '2.0'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: bundler
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -263,7 +263,7 @@ dependencies:
|
|
263
263
|
- - ">="
|
264
264
|
- !ruby/object:Gem::Version
|
265
265
|
version: '0'
|
266
|
-
description:
|
266
|
+
description:
|
267
267
|
email:
|
268
268
|
- jonas@thiel.io
|
269
269
|
executables:
|
@@ -356,7 +356,7 @@ homepage: https://github.com/jnbt/candy_check
|
|
356
356
|
licenses:
|
357
357
|
- MIT
|
358
358
|
metadata: {}
|
359
|
-
post_install_message:
|
359
|
+
post_install_message:
|
360
360
|
rdoc_options: []
|
361
361
|
require_paths:
|
362
362
|
- lib
|
@@ -371,8 +371,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
371
371
|
- !ruby/object:Gem::Version
|
372
372
|
version: '0'
|
373
373
|
requirements: []
|
374
|
-
rubygems_version: 3.1.
|
375
|
-
signing_key:
|
374
|
+
rubygems_version: 3.1.4
|
375
|
+
signing_key:
|
376
376
|
specification_version: 4
|
377
377
|
summary: Check and verify in-app receipts
|
378
378
|
test_files:
|