candy_check 0.3.0 → 0.5.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/.github/workflows/build.yml +34 -0
- data/.gitignore +2 -1
- data/.ruby-version +1 -1
- data/README.md +2 -2
- data/candy_check.gemspec +7 -5
- data/lib/candy_check/cli/app.rb +6 -2
- data/lib/candy_check/play_store.rb +2 -1
- 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/fixtures/vcr_cassettes/play_store/product_acknowledgements/acknowledged.yml +1 -1
- data/spec/fixtures/vcr_cassettes/play_store/product_acknowledgements/already_acknowledged.yml +1 -1
- data/spec/fixtures/vcr_cassettes/play_store/product_acknowledgements/refunded.yml +1 -1
- data/spec/fixtures/vcr_cassettes/play_store/product_purchases/permission_denied.yml +2 -2
- data/spec/fixtures/vcr_cassettes/play_store/product_purchases/response_with_empty_body.yml +2 -2
- data/spec/fixtures/vcr_cassettes/play_store/product_purchases/valid_but_not_consumed.yml +1 -1
- data/spec/fixtures/vcr_cassettes/play_store/subscription_purchases/permission_denied.yml +2 -2
- data/spec/fixtures/vcr_cassettes/play_store/subscription_purchases/valid_but_expired.yml +1 -1
- 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 +12 -12
- data/spec/play_store/product_purchases/product_verification_spec.rb +7 -7
- data/spec/play_store/subscription_purchases/subscription_purchase_spec.rb +26 -26
- 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/spec_helper.rb +15 -2
- data/spec/support/with_command.rb +0 -3
- metadata +53 -25
- data/.travis.yml +0 -18
@@ -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
|
]
|
@@ -51,7 +51,7 @@ http_interactions:
|
|
51
51
|
recorded_at: Mon, 22 Jun 2020 11:38:56 GMT
|
52
52
|
- request:
|
53
53
|
method: post
|
54
|
-
uri: https://
|
54
|
+
uri: https://androidpublisher.googleapis.com/androidpublisher/v3/applications/fake_package_name/purchases/products/fake_product_id/tokens/fake_token:acknowledge
|
55
55
|
body:
|
56
56
|
encoding: UTF-8
|
57
57
|
string: ''
|
data/spec/fixtures/vcr_cassettes/play_store/product_acknowledgements/already_acknowledged.yml
CHANGED
@@ -51,7 +51,7 @@ http_interactions:
|
|
51
51
|
recorded_at: Mon, 22 Jun 2020 13:11:45 GMT
|
52
52
|
- request:
|
53
53
|
method: post
|
54
|
-
uri: https://
|
54
|
+
uri: https://androidpublisher.googleapis.com/androidpublisher/v3/applications/fake_package_name/purchases/products/fake_product_id/tokens/fake_token:acknowledge
|
55
55
|
body:
|
56
56
|
encoding: UTF-8
|
57
57
|
string: ''
|
@@ -51,7 +51,7 @@ http_interactions:
|
|
51
51
|
recorded_at: Mon, 22 Jun 2020 14:37:46 GMT
|
52
52
|
- request:
|
53
53
|
method: post
|
54
|
-
uri: https://
|
54
|
+
uri: https://androidpublisher.googleapis.com/androidpublisher/v3/applications/fake_package_name/purchases/products/fake_product_id/tokens/fake_token:acknowledge
|
55
55
|
body:
|
56
56
|
encoding: UTF-8
|
57
57
|
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://
|
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://
|
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://
|
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://
|
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://
|
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://
|
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://
|
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://
|
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: ''
|
@@ -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
|
|
@@ -99,7 +99,7 @@ describe CandyCheck::PlayStore::ProductPurchases::ProductPurchase do
|
|
99
99
|
:purchase_time_millis,
|
100
100
|
].freeze
|
101
101
|
|
102
|
-
attr_accessor
|
102
|
+
attr_accessor(*FIELDS)
|
103
103
|
|
104
104
|
def initialize(hash)
|
105
105
|
FIELDS.each do |key|
|
@@ -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
|
|
@@ -226,7 +226,7 @@ describe CandyCheck::PlayStore::SubscriptionPurchases::SubscriptionPurchase do
|
|
226
226
|
:price_currency_code,
|
227
227
|
].freeze
|
228
228
|
|
229
|
-
attr_accessor
|
229
|
+
attr_accessor(*FIELDS)
|
230
230
|
|
231
231
|
def initialize(hash)
|
232
232
|
FIELDS.each do |key|
|
@@ -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
|
|