stripe 3.3.2 → 3.4.1
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 +1 -0
- data/.rubocop.yml +20 -0
- data/.rubocop_todo.yml +62 -0
- data/.travis.yml +1 -1
- data/Gemfile +19 -12
- data/History.txt +10 -0
- data/README.md +5 -1
- data/Rakefile +8 -5
- data/VERSION +1 -1
- data/bin/stripe-console +2 -2
- data/lib/stripe.rb +72 -74
- data/lib/stripe/account.rb +15 -17
- data/lib/stripe/alipay_account.rb +10 -7
- data/lib/stripe/api_operations/create.rb +1 -1
- data/lib/stripe/api_operations/delete.rb +1 -1
- data/lib/stripe/api_operations/list.rb +2 -2
- data/lib/stripe/api_operations/request.rb +5 -12
- data/lib/stripe/api_operations/save.rb +6 -6
- data/lib/stripe/api_resource.rb +7 -9
- data/lib/stripe/apple_pay_domain.rb +2 -2
- data/lib/stripe/application_fee.rb +5 -5
- data/lib/stripe/application_fee_refund.rb +5 -5
- data/lib/stripe/balance.rb +1 -1
- data/lib/stripe/balance_transaction.rb +2 -2
- data/lib/stripe/bank_account.rb +7 -7
- data/lib/stripe/bitcoin_receiver.rb +4 -2
- data/lib/stripe/bitcoin_transaction.rb +3 -1
- data/lib/stripe/card.rb +5 -5
- data/lib/stripe/charge.rb +18 -18
- data/lib/stripe/country_spec.rb +2 -2
- data/lib/stripe/coupon.rb +1 -1
- data/lib/stripe/customer.rb +23 -23
- data/lib/stripe/dispute.rb +3 -3
- data/lib/stripe/ephemeral_key.rb +4 -4
- data/lib/stripe/errors.rb +4 -4
- data/lib/stripe/event.rb +1 -1
- data/lib/stripe/file_upload.rb +5 -5
- data/lib/stripe/invoice.rb +7 -7
- data/lib/stripe/invoice_item.rb +1 -1
- data/lib/stripe/invoice_line_item.rb +1 -1
- data/lib/stripe/list_object.rb +14 -18
- data/lib/stripe/login_link.rb +3 -3
- data/lib/stripe/oauth.rb +15 -13
- data/lib/stripe/order.rb +5 -5
- data/lib/stripe/order_return.rb +1 -1
- data/lib/stripe/payout.rb +3 -3
- data/lib/stripe/plan.rb +1 -1
- data/lib/stripe/product.rb +1 -1
- data/lib/stripe/recipient.rb +3 -2
- data/lib/stripe/recipient_transfer.rb +1 -2
- data/lib/stripe/refund.rb +1 -1
- data/lib/stripe/reversal.rb +5 -5
- data/lib/stripe/singleton_api_resource.rb +3 -3
- data/lib/stripe/sku.rb +1 -1
- data/lib/stripe/source.rb +13 -10
- data/lib/stripe/stripe_client.rb +149 -169
- data/lib/stripe/stripe_object.rb +77 -76
- data/lib/stripe/subscription.rb +5 -5
- data/lib/stripe/subscription_item.rb +2 -2
- data/lib/stripe/three_d_secure.rb +1 -1
- data/lib/stripe/token.rb +1 -1
- data/lib/stripe/transfer.rb +3 -3
- data/lib/stripe/util.rb +77 -62
- data/lib/stripe/version.rb +1 -1
- data/lib/stripe/webhook.rb +14 -10
- data/stripe.gemspec +14 -14
- data/test/stripe/account_test.rb +69 -81
- data/test/stripe/alipay_account_test.rb +19 -1
- data/test/stripe/api_operations_test.rb +7 -7
- data/test/stripe/api_resource_test.rb +224 -260
- data/test/stripe/apple_pay_domain_test.rb +8 -8
- data/test/stripe/application_fee_refund_test.rb +8 -8
- data/test/stripe/application_fee_test.rb +3 -3
- data/test/stripe/balance_test.rb +2 -2
- data/test/stripe/bank_account_test.rb +9 -11
- data/test/stripe/charge_test.rb +11 -11
- data/test/stripe/country_spec_test.rb +4 -4
- data/test/stripe/coupon_test.rb +10 -10
- data/test/stripe/customer_card_test.rb +11 -15
- data/test/stripe/customer_test.rb +26 -27
- data/test/stripe/dispute_test.rb +8 -8
- data/test/stripe/ephemeral_key_test.rb +14 -14
- data/test/stripe/errors_test.rb +2 -2
- data/test/stripe/file_upload_test.rb +26 -28
- data/test/stripe/invoice_item_test.rb +14 -14
- data/test/stripe/invoice_line_item_test.rb +1 -1
- data/test/stripe/invoice_test.rb +37 -37
- data/test/stripe/list_object_test.rb +60 -76
- data/test/stripe/login_link_test.rb +14 -14
- data/test/stripe/oauth_test.rb +42 -50
- data/test/stripe/order_return_test.rb +5 -5
- data/test/stripe/order_test.rb +12 -12
- data/test/stripe/payout_test.rb +9 -9
- data/test/stripe/plan_test.rb +9 -9
- data/test/stripe/product_test.rb +8 -8
- data/test/stripe/recipient_test.rb +9 -10
- data/test/stripe/refund_test.rb +9 -9
- data/test/stripe/reversal_test.rb +10 -10
- data/test/stripe/sku_test.rb +8 -8
- data/test/stripe/source_test.rb +14 -16
- data/test/stripe/stripe_client_test.rb +235 -266
- data/test/stripe/stripe_object_test.rb +163 -147
- data/test/stripe/stripe_response_test.rb +4 -3
- data/test/stripe/subscription_item_test.rb +11 -11
- data/test/stripe/subscription_test.rb +14 -14
- data/test/stripe/three_d_secure_test.rb +2 -2
- data/test/stripe/transfer_test.rb +8 -8
- data/test/stripe/util_test.rb +59 -57
- data/test/stripe/webhook_test.rb +18 -16
- data/test/stripe_test.rb +4 -4
- data/test/test_data.rb +26 -26
- data/test/test_helper.rb +29 -25
- metadata +6 -10
- data/test/stripe/bitcoin_receiver_test.rb +0 -67
- data/test/stripe/bitcoin_transaction_test.rb +0 -19
- data/test/stripe/recipient_card_test.rb +0 -44
@@ -1,35 +1,35 @@
|
|
1
|
-
require File.expand_path(
|
1
|
+
require File.expand_path("../../test_helper", __FILE__)
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class LoginLinkTest < Test::Unit::TestCase
|
5
5
|
setup do
|
6
6
|
account_fixture = {
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
}
|
7
|
+
"id" => "acct_123",
|
8
|
+
"object" => "account",
|
9
|
+
"login_links" => {
|
10
|
+
"data" => [],
|
11
|
+
"has_more" => false,
|
12
|
+
"object" => "list",
|
13
|
+
"url" => "/v1/accounts/acct_123/login_links",
|
14
|
+
},
|
15
15
|
}
|
16
16
|
@account = Stripe::Account.construct_from(account_fixture)
|
17
17
|
end
|
18
18
|
|
19
19
|
should "not be retrievable" do
|
20
20
|
assert_raises NotImplementedError do
|
21
|
-
Stripe::LoginLink.retrieve(
|
21
|
+
Stripe::LoginLink.retrieve("foo")
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
25
|
should "be creatable" do
|
26
|
-
stub_request(:post, "#{Stripe.api_base}/v1/accounts/#{@account.id}/login_links")
|
27
|
-
to_return(body: JSON.generate(
|
26
|
+
stub_request(:post, "#{Stripe.api_base}/v1/accounts/#{@account.id}/login_links")
|
27
|
+
.to_return(body: JSON.generate(object: "login_link"))
|
28
28
|
|
29
29
|
login_link = @account.login_links.create
|
30
30
|
assert_requested :post,
|
31
|
-
|
32
|
-
assert login_link.
|
31
|
+
"#{Stripe.api_base}/v1/accounts/#{@account.id}/login_links"
|
32
|
+
assert login_link.is_a?(Stripe::LoginLink)
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
data/test/stripe/oauth_test.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
require File.expand_path(
|
1
|
+
require File.expand_path("../../test_helper", __FILE__)
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class OAuthTest < Test::Unit::TestCase
|
5
5
|
setup do
|
6
|
-
Stripe.client_id =
|
6
|
+
Stripe.client_id = "ca_test"
|
7
7
|
end
|
8
8
|
|
9
9
|
teardown do
|
@@ -12,28 +12,26 @@ module Stripe
|
|
12
12
|
|
13
13
|
context ".authorize_url" do
|
14
14
|
should "return the authorize URL" do
|
15
|
-
uri_str = OAuth.authorize_url(
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
},
|
23
|
-
})
|
15
|
+
uri_str = OAuth.authorize_url(scope: "read_write",
|
16
|
+
state: "csrf_token",
|
17
|
+
stripe_user: {
|
18
|
+
email: "test@example.com",
|
19
|
+
url: "https://example.com/profile/test",
|
20
|
+
country: "US",
|
21
|
+
})
|
24
22
|
|
25
|
-
uri = URI
|
26
|
-
params = CGI
|
23
|
+
uri = URI.parse(uri_str)
|
24
|
+
params = CGI.parse(uri.query)
|
27
25
|
|
28
|
-
assert_equal(
|
29
|
-
assert_equal(
|
30
|
-
assert_equal(
|
26
|
+
assert_equal("https", uri.scheme)
|
27
|
+
assert_equal("connect.stripe.com", uri.host)
|
28
|
+
assert_equal("/oauth/authorize", uri.path)
|
31
29
|
|
32
|
-
assert_equal([
|
33
|
-
assert_equal([
|
34
|
-
assert_equal([
|
35
|
-
assert_equal([
|
36
|
-
assert_equal([
|
30
|
+
assert_equal(["ca_test"], params["client_id"])
|
31
|
+
assert_equal(["read_write"], params["scope"])
|
32
|
+
assert_equal(["test@example.com"], params["stripe_user[email]"])
|
33
|
+
assert_equal(["https://example.com/profile/test"], params["stripe_user[url]"])
|
34
|
+
assert_equal(["US"], params["stripe_user[country]"])
|
37
35
|
end
|
38
36
|
end
|
39
37
|
|
@@ -41,26 +39,22 @@ module Stripe
|
|
41
39
|
should "exchange a code for an access token" do
|
42
40
|
# The OpenAPI fixtures don't cover the OAuth endpoints, so we just
|
43
41
|
# stub the request manually.
|
44
|
-
stub_request(:post, "#{Stripe.connect_base}/oauth/token")
|
45
|
-
with(body: {
|
46
|
-
|
47
|
-
|
48
|
-
})
|
49
|
-
to_return(body: JSON.generate(
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
stripe_publishable_key: 'pk_test',
|
57
|
-
}))
|
42
|
+
stub_request(:post, "#{Stripe.connect_base}/oauth/token")
|
43
|
+
.with(body: {
|
44
|
+
"grant_type" => "authorization_code",
|
45
|
+
"code" => "this_is_an_authorization_code",
|
46
|
+
})
|
47
|
+
.to_return(body: JSON.generate(access_token: "sk_access_token",
|
48
|
+
scope: "read_only",
|
49
|
+
livemode: false,
|
50
|
+
token_type: "bearer",
|
51
|
+
refresh_token: "sk_refresh_token",
|
52
|
+
stripe_user_id: "acct_test",
|
53
|
+
stripe_publishable_key: "pk_test"))
|
58
54
|
|
59
|
-
resp = OAuth.token(
|
60
|
-
|
61
|
-
|
62
|
-
})
|
63
|
-
assert_equal('sk_access_token', resp.access_token)
|
55
|
+
resp = OAuth.token(grant_type: "authorization_code",
|
56
|
+
code: "this_is_an_authorization_code")
|
57
|
+
assert_equal("sk_access_token", resp.access_token)
|
64
58
|
end
|
65
59
|
end
|
66
60
|
|
@@ -68,17 +62,15 @@ module Stripe
|
|
68
62
|
should "deauthorize an account" do
|
69
63
|
# The OpenAPI fixtures don't cover the OAuth endpoints, so we just
|
70
64
|
# stub the request manually.
|
71
|
-
stub_request(:post, "#{Stripe.connect_base}/oauth/deauthorize")
|
72
|
-
with(body: {
|
73
|
-
|
74
|
-
|
75
|
-
})
|
76
|
-
to_return(body: JSON.generate(
|
77
|
-
stripe_user_id: 'acct_test_deauth',
|
78
|
-
}))
|
65
|
+
stub_request(:post, "#{Stripe.connect_base}/oauth/deauthorize")
|
66
|
+
.with(body: {
|
67
|
+
"client_id" => "ca_test",
|
68
|
+
"stripe_user_id" => "acct_test_deauth",
|
69
|
+
})
|
70
|
+
.to_return(body: JSON.generate(stripe_user_id: "acct_test_deauth"))
|
79
71
|
|
80
|
-
resp = OAuth.deauthorize(
|
81
|
-
assert_equal(
|
72
|
+
resp = OAuth.deauthorize(stripe_user_id: "acct_test_deauth")
|
73
|
+
assert_equal("acct_test_deauth", resp.stripe_user_id)
|
82
74
|
end
|
83
75
|
end
|
84
76
|
end
|
@@ -1,19 +1,19 @@
|
|
1
|
-
require File.expand_path(
|
1
|
+
require File.expand_path("../../test_helper", __FILE__)
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class OrderReturnTest < Test::Unit::TestCase
|
5
5
|
should "be listable" do
|
6
6
|
order_returns = Stripe::OrderReturn.list
|
7
7
|
assert_requested :get, "#{Stripe.api_base}/v1/order_returns"
|
8
|
-
assert order_returns.data.
|
9
|
-
assert order_returns.data[0].
|
8
|
+
assert order_returns.data.is_a?(Array)
|
9
|
+
assert order_returns.data[0].is_a?(Stripe::OrderReturn)
|
10
10
|
end
|
11
11
|
|
12
12
|
should "be retrievable" do
|
13
13
|
order_return = Stripe::OrderReturn.retrieve("orret_123")
|
14
14
|
assert_requested :get,
|
15
|
-
|
16
|
-
assert order_return.
|
15
|
+
"#{Stripe.api_base}/v1/order_returns/orret_123"
|
16
|
+
assert order_return.is_a?(Stripe::OrderReturn)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
data/test/stripe/order_test.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
|
-
require File.expand_path(
|
1
|
+
require File.expand_path("../../test_helper", __FILE__)
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class OrderTest < Test::Unit::TestCase
|
5
5
|
should "be listable" do
|
6
6
|
orders = Stripe::Order.list
|
7
7
|
assert_requested :get, "#{Stripe.api_base}/v1/orders"
|
8
|
-
assert orders.data.
|
9
|
-
assert orders.first.
|
8
|
+
assert orders.data.is_a?(Array)
|
9
|
+
assert orders.first.is_a?(Stripe::Order)
|
10
10
|
end
|
11
11
|
|
12
12
|
should "be retrievable" do
|
13
13
|
order = Stripe::Order.retrieve("or_123")
|
14
14
|
assert_requested :get, "#{Stripe.api_base}/v1/orders/or_123"
|
15
|
-
assert order.
|
15
|
+
assert order.is_a?(Stripe::Order)
|
16
16
|
end
|
17
17
|
|
18
18
|
should "be creatable" do
|
@@ -20,37 +20,37 @@ module Stripe
|
|
20
20
|
currency: "USD"
|
21
21
|
)
|
22
22
|
assert_requested :post, "#{Stripe.api_base}/v1/orders"
|
23
|
-
assert order.
|
23
|
+
assert order.is_a?(Stripe::Order)
|
24
24
|
end
|
25
25
|
|
26
26
|
should "be saveable" do
|
27
27
|
order = Stripe::Order.retrieve("or_123")
|
28
|
-
order.metadata[
|
28
|
+
order.metadata["key"] = "value"
|
29
29
|
order.save
|
30
30
|
assert_requested :post, "#{Stripe.api_base}/v1/orders/#{order.id}"
|
31
31
|
end
|
32
32
|
|
33
33
|
should "be updateable" do
|
34
|
-
order = Stripe::Order.update("or_123", metadata: { key:
|
34
|
+
order = Stripe::Order.update("or_123", metadata: { key: "value" })
|
35
35
|
assert_requested :post, "#{Stripe.api_base}/v1/orders/or_123"
|
36
|
-
assert order.
|
36
|
+
assert order.is_a?(Stripe::Order)
|
37
37
|
end
|
38
38
|
|
39
39
|
context "#pay" do
|
40
40
|
should "pay an order" do
|
41
41
|
order = Stripe::Order.retrieve("or_123")
|
42
42
|
order = order.pay(token: "tok_123")
|
43
|
-
assert order.
|
43
|
+
assert order.is_a?(Stripe::Order)
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
47
|
context "#return_order" do
|
48
48
|
should "return an order" do
|
49
49
|
order = Stripe::Order.retrieve("or_123")
|
50
|
-
order = order.return_order(:
|
51
|
-
{ parent: "sku_123" }
|
50
|
+
order = order.return_order(orders: [
|
51
|
+
{ parent: "sku_123" },
|
52
52
|
])
|
53
|
-
assert order.
|
53
|
+
assert order.is_a?(Stripe::OrderReturn)
|
54
54
|
end
|
55
55
|
end
|
56
56
|
end
|
data/test/stripe/payout_test.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
|
-
require File.expand_path(
|
1
|
+
require File.expand_path("../../test_helper", __FILE__)
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class PayoutTest < Test::Unit::TestCase
|
5
5
|
should "be listable" do
|
6
6
|
payouts = Stripe::Payout.list
|
7
7
|
assert_requested :get, "#{Stripe.api_base}/v1/payouts"
|
8
|
-
assert payouts.data.
|
9
|
-
assert payouts.data[0].
|
8
|
+
assert payouts.data.is_a?(Array)
|
9
|
+
assert payouts.data[0].is_a?(Stripe::Payout)
|
10
10
|
end
|
11
11
|
|
12
12
|
should "be retrievable" do
|
13
13
|
payout = Stripe::Payout.retrieve("tr_123")
|
14
14
|
assert_requested :get, "#{Stripe.api_base}/v1/payouts/tr_123"
|
15
|
-
assert payout.
|
15
|
+
assert payout.is_a?(Stripe::Payout)
|
16
16
|
end
|
17
17
|
|
18
18
|
should "be creatable" do
|
@@ -21,27 +21,27 @@ module Stripe
|
|
21
21
|
currency: "USD"
|
22
22
|
)
|
23
23
|
assert_requested :post, "#{Stripe.api_base}/v1/payouts"
|
24
|
-
assert payout.
|
24
|
+
assert payout.is_a?(Stripe::Payout)
|
25
25
|
end
|
26
26
|
|
27
27
|
should "be saveable" do
|
28
28
|
payout = Stripe::Payout.retrieve("tr_123")
|
29
|
-
payout.metadata[
|
29
|
+
payout.metadata["key"] = "value"
|
30
30
|
payout.save
|
31
31
|
assert_requested :post, "#{Stripe.api_base}/v1/payouts/#{payout.id}"
|
32
32
|
end
|
33
33
|
|
34
34
|
should "be updateable" do
|
35
|
-
payout = Stripe::Payout.update("tr_123", metadata: {foo:
|
35
|
+
payout = Stripe::Payout.update("tr_123", metadata: { foo: "bar" })
|
36
36
|
assert_requested :post, "#{Stripe.api_base}/v1/payouts/tr_123"
|
37
|
-
assert payout.
|
37
|
+
assert payout.is_a?(Stripe::Payout)
|
38
38
|
end
|
39
39
|
|
40
40
|
context "#cancel" do
|
41
41
|
should "cancel a payout" do
|
42
42
|
payout = Stripe::Payout.retrieve("tr_123")
|
43
43
|
payout = payout.cancel
|
44
|
-
assert payout.
|
44
|
+
assert payout.is_a?(Stripe::Payout)
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
data/test/stripe/plan_test.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
|
-
require File.expand_path(
|
1
|
+
require File.expand_path("../../test_helper", __FILE__)
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class PlanTest < Test::Unit::TestCase
|
5
5
|
should "be listable" do
|
6
6
|
plans = Stripe::Plan.list
|
7
7
|
assert_requested :get, "#{Stripe.api_base}/v1/plans"
|
8
|
-
assert plans.data.
|
9
|
-
assert plans.data[0].
|
8
|
+
assert plans.data.is_a?(Array)
|
9
|
+
assert plans.data[0].is_a?(Stripe::Plan)
|
10
10
|
end
|
11
11
|
|
12
12
|
should "be retrievable" do
|
13
13
|
plan = Stripe::Plan.retrieve("sapphire-elite")
|
14
14
|
assert_requested :get, "#{Stripe.api_base}/v1/plans/sapphire-elite"
|
15
|
-
assert plan.
|
15
|
+
assert plan.is_a?(Stripe::Plan)
|
16
16
|
end
|
17
17
|
|
18
18
|
should "be creatable" do
|
@@ -24,27 +24,27 @@ module Stripe
|
|
24
24
|
id: "sapphire-elite"
|
25
25
|
)
|
26
26
|
assert_requested :post, "#{Stripe.api_base}/v1/plans"
|
27
|
-
assert plan.
|
27
|
+
assert plan.is_a?(Stripe::Plan)
|
28
28
|
end
|
29
29
|
|
30
30
|
should "be saveable" do
|
31
31
|
plan = Stripe::Plan.retrieve("sapphire-elite")
|
32
|
-
plan.metadata[
|
32
|
+
plan.metadata["key"] = "value"
|
33
33
|
plan.save
|
34
34
|
assert_requested :post, "#{Stripe.api_base}/v1/plans/#{plan.id}"
|
35
35
|
end
|
36
36
|
|
37
37
|
should "be updateable" do
|
38
|
-
plan = Stripe::Plan.update("sapphire-elite", metadata: {foo:
|
38
|
+
plan = Stripe::Plan.update("sapphire-elite", metadata: { foo: "bar" })
|
39
39
|
assert_requested :post, "#{Stripe.api_base}/v1/plans/sapphire-elite"
|
40
|
-
assert plan.
|
40
|
+
assert plan.is_a?(Stripe::Plan)
|
41
41
|
end
|
42
42
|
|
43
43
|
should "be deletable" do
|
44
44
|
plan = Stripe::Plan.retrieve("sapphire-elite")
|
45
45
|
plan = plan.delete
|
46
46
|
assert_requested :delete, "#{Stripe.api_base}/v1/plans/#{plan.id}"
|
47
|
-
assert plan.
|
47
|
+
assert plan.is_a?(Stripe::Plan)
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
data/test/stripe/product_test.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
|
-
require File.expand_path(
|
1
|
+
require File.expand_path("../../test_helper", __FILE__)
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class ProductTest < Test::Unit::TestCase
|
5
5
|
should "be listable" do
|
6
6
|
products = Stripe::Product.list
|
7
7
|
assert_requested :get, "#{Stripe.api_base}/v1/products"
|
8
|
-
assert products.data.
|
9
|
-
assert products.data[0].
|
8
|
+
assert products.data.is_a?(Array)
|
9
|
+
assert products.data[0].is_a?(Stripe::Product)
|
10
10
|
end
|
11
11
|
|
12
12
|
should "be retrievable" do
|
13
13
|
product = Stripe::Product.retrieve("prod_123")
|
14
14
|
assert_requested :get, "#{Stripe.api_base}/v1/products/prod_123"
|
15
|
-
assert product.
|
15
|
+
assert product.is_a?(Stripe::Product)
|
16
16
|
end
|
17
17
|
|
18
18
|
should "be creatable" do
|
@@ -24,22 +24,22 @@ module Stripe
|
|
24
24
|
|
25
25
|
should "be saveable" do
|
26
26
|
product = Stripe::Product.retrieve("prod_123")
|
27
|
-
product.metadata[
|
27
|
+
product.metadata["key"] = "value"
|
28
28
|
product.save
|
29
29
|
assert_requested :post, "#{Stripe.api_base}/v1/products/#{product.id}"
|
30
30
|
end
|
31
31
|
|
32
32
|
should "be updateable" do
|
33
|
-
product = Stripe::Product.update("prod_123", metadata: {foo:
|
33
|
+
product = Stripe::Product.update("prod_123", metadata: { foo: "bar" })
|
34
34
|
assert_requested :post, "#{Stripe.api_base}/v1/products/prod_123"
|
35
|
-
assert product.
|
35
|
+
assert product.is_a?(Stripe::Product)
|
36
36
|
end
|
37
37
|
|
38
38
|
should "be deletable" do
|
39
39
|
product = Stripe::Product.retrieve("prod_123")
|
40
40
|
product = product.delete
|
41
41
|
assert_requested :delete, "#{Stripe.api_base}/v1/products/#{product.id}"
|
42
|
-
assert product.
|
42
|
+
assert product.is_a?(Stripe::Product)
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
@@ -1,18 +1,18 @@
|
|
1
|
-
require File.expand_path(
|
1
|
+
require File.expand_path("../../test_helper", __FILE__)
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class RecipientTest < Test::Unit::TestCase
|
5
5
|
should "be listable" do
|
6
6
|
recipients = Stripe::Recipient.list
|
7
7
|
assert_requested :get, "#{Stripe.api_base}/v1/recipients"
|
8
|
-
assert recipients.data.
|
9
|
-
assert recipients.data[0].
|
8
|
+
assert recipients.data.is_a?(Array)
|
9
|
+
assert recipients.data[0].is_a?(Stripe::Recipient)
|
10
10
|
end
|
11
11
|
|
12
12
|
should "be retrievable" do
|
13
13
|
recipient = Stripe::Recipient.retrieve("rp_123")
|
14
14
|
assert_requested :get, "#{Stripe.api_base}/v1/recipients/rp_123"
|
15
|
-
assert recipient.
|
15
|
+
assert recipient.is_a?(Stripe::Recipient)
|
16
16
|
end
|
17
17
|
|
18
18
|
should "be creatable" do
|
@@ -21,28 +21,27 @@ module Stripe
|
|
21
21
|
type: "individual"
|
22
22
|
)
|
23
23
|
assert_requested :post, "#{Stripe.api_base}/v1/recipients"
|
24
|
-
assert recipient.
|
24
|
+
assert recipient.is_a?(Stripe::Recipient)
|
25
25
|
end
|
26
26
|
|
27
27
|
should "be saveable" do
|
28
28
|
recipient = Stripe::Recipient.retrieve("rp_123")
|
29
|
-
recipient.metadata[
|
29
|
+
recipient.metadata["key"] = "value"
|
30
30
|
recipient.save
|
31
31
|
assert_requested :post, "#{Stripe.api_base}/v1/recipients/#{recipient.id}"
|
32
32
|
end
|
33
33
|
|
34
34
|
should "be updateable" do
|
35
|
-
recipient = Stripe::Recipient.update("rp_123", metadata: {foo:
|
35
|
+
recipient = Stripe::Recipient.update("rp_123", metadata: { foo: "bar" })
|
36
36
|
assert_requested :post, "#{Stripe.api_base}/v1/recipients/rp_123"
|
37
|
-
assert recipient.
|
37
|
+
assert recipient.is_a?(Stripe::Recipient)
|
38
38
|
end
|
39
39
|
|
40
40
|
should "be deletable" do
|
41
41
|
recipient = Stripe::Recipient.retrieve("rp_123")
|
42
42
|
recipient = recipient.delete
|
43
43
|
assert_requested :delete, "#{Stripe.api_base}/v1/recipients/#{recipient.id}"
|
44
|
-
assert recipient.
|
44
|
+
assert recipient.is_a?(Stripe::Recipient)
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
48
|
-
|