stripe 3.0.3 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +23 -0
- data/Gemfile +1 -2
- data/History.txt +4 -0
- data/README.md +28 -3
- data/Rakefile +0 -12
- data/VERSION +1 -1
- data/lib/stripe.rb +24 -0
- data/lib/stripe/stripe_client.rb +166 -19
- data/lib/stripe/util.rb +127 -8
- data/lib/stripe/version.rb +1 -1
- data/test/api_stub_helpers.rb +0 -125
- data/test/stripe/account_test.rb +11 -13
- data/test/stripe/alipay_account_test.rb +2 -4
- data/test/stripe/api_resource_test.rb +112 -76
- data/test/stripe/apple_pay_domain_test.rb +4 -6
- data/test/stripe/application_fee_refund_test.rb +2 -5
- data/test/stripe/application_fee_test.rb +0 -2
- data/test/stripe/bank_account_test.rb +8 -13
- data/test/stripe/bitcoin_receiver_test.rb +13 -16
- data/test/stripe/bitcoin_transaction_test.rb +2 -4
- data/test/stripe/charge_test.rb +9 -11
- data/test/stripe/country_spec_test.rb +2 -4
- data/test/stripe/coupon_test.rb +6 -8
- data/test/stripe/customer_card_test.rb +13 -9
- data/test/stripe/customer_test.rb +16 -18
- data/test/stripe/dispute_test.rb +8 -10
- data/test/stripe/file_upload_test.rb +3 -3
- data/test/stripe/invoice_item_test.rb +9 -11
- data/test/stripe/invoice_line_item_test.rb +0 -1
- data/test/stripe/invoice_test.rb +39 -21
- data/test/stripe/list_object_test.rb +1 -1
- data/test/stripe/login_link_test.rb +6 -7
- data/test/stripe/order_return_test.rb +2 -4
- data/test/stripe/order_test.rb +10 -12
- data/test/stripe/payout_test.rb +7 -9
- data/test/stripe/plan_test.rb +8 -10
- data/test/stripe/product_test.rb +8 -10
- data/test/stripe/recipient_card_test.rb +13 -9
- data/test/stripe/recipient_test.rb +8 -10
- data/test/stripe/refund_test.rb +7 -9
- data/test/stripe/reversal_test.rb +5 -7
- data/test/stripe/sku_test.rb +9 -11
- data/test/stripe/source_test.rb +16 -15
- data/test/stripe/stripe_client_test.rb +190 -26
- data/test/stripe/subscription_item_test.rb +12 -14
- data/test/stripe/subscription_test.rb +10 -12
- data/test/stripe/three_d_secure_test.rb +3 -5
- data/test/stripe/transfer_test.rb +7 -9
- data/test/stripe/util_test.rb +164 -0
- data/test/test_helper.rb +33 -18
- metadata +2 -8
- data/openapi/fixtures.json +0 -1896
- data/openapi/fixtures.yaml +0 -1505
- data/openapi/spec2.json +0 -24601
- data/openapi/spec2.yaml +0 -18801
- data/test/api_fixtures.rb +0 -29
@@ -2,52 +2,50 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class SubscriptionItemTest < Test::Unit::TestCase
|
5
|
-
FIXTURE = API_FIXTURES.fetch(:subscription_item)
|
6
|
-
|
7
5
|
should "be listable" do
|
8
6
|
items = Stripe::SubscriptionItem.list(
|
9
|
-
subscription:
|
7
|
+
subscription: "sub_123",
|
10
8
|
)
|
11
9
|
assert_requested :get, "#{Stripe.api_base}/v1/subscription_items",
|
12
|
-
query: { subscription:
|
10
|
+
query: { subscription: "sub_123" }
|
13
11
|
assert items.data.kind_of?(Array)
|
14
12
|
assert items.data[0].kind_of?(Stripe::SubscriptionItem)
|
15
13
|
end
|
16
14
|
|
17
15
|
should "be retrievable" do
|
18
|
-
item = Stripe::SubscriptionItem.retrieve(
|
19
|
-
assert_requested :get, "#{Stripe.api_base}/v1/subscription_items
|
16
|
+
item = Stripe::SubscriptionItem.retrieve("si_123")
|
17
|
+
assert_requested :get, "#{Stripe.api_base}/v1/subscription_items/si_123"
|
20
18
|
assert item.kind_of?(Stripe::SubscriptionItem)
|
21
19
|
end
|
22
20
|
|
23
21
|
should "be creatable" do
|
24
22
|
item = Stripe::SubscriptionItem.create(
|
25
23
|
item: 'silver',
|
26
|
-
plan:
|
24
|
+
plan: "sapphire-elite",
|
27
25
|
quantity: 3,
|
28
|
-
subscription:
|
26
|
+
subscription: "sub_123"
|
29
27
|
)
|
30
28
|
assert_requested :post, "#{Stripe.api_base}/v1/subscription_items"
|
31
29
|
assert item.kind_of?(Stripe::SubscriptionItem)
|
32
30
|
end
|
33
31
|
|
34
32
|
should "be saveable" do
|
35
|
-
item = Stripe::SubscriptionItem.retrieve(
|
33
|
+
item = Stripe::SubscriptionItem.retrieve("si_123")
|
36
34
|
item.quantity = 4
|
37
35
|
item.save
|
38
|
-
assert_requested :post, "#{Stripe.api_base}/v1/subscription_items/#{
|
36
|
+
assert_requested :post, "#{Stripe.api_base}/v1/subscription_items/#{item.id}"
|
39
37
|
end
|
40
38
|
|
41
39
|
should "be updateable" do
|
42
|
-
item = Stripe::SubscriptionItem.update(
|
43
|
-
assert_requested :post, "#{Stripe.api_base}/v1/subscription_items
|
40
|
+
item = Stripe::SubscriptionItem.update("si_123", metadata: {foo: 'bar'})
|
41
|
+
assert_requested :post, "#{Stripe.api_base}/v1/subscription_items/si_123"
|
44
42
|
assert item.kind_of?(Stripe::SubscriptionItem)
|
45
43
|
end
|
46
44
|
|
47
45
|
should "be deletable" do
|
48
|
-
item = Stripe::SubscriptionItem.retrieve(
|
46
|
+
item = Stripe::SubscriptionItem.retrieve("si_123")
|
49
47
|
item = item.delete
|
50
|
-
assert_requested :delete, "#{Stripe.api_base}/v1/subscription_items/#{
|
48
|
+
assert_requested :delete, "#{Stripe.api_base}/v1/subscription_items/#{item.id}"
|
51
49
|
assert item.kind_of?(Stripe::SubscriptionItem)
|
52
50
|
end
|
53
51
|
end
|
@@ -2,8 +2,6 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class SubscriptionTest < Test::Unit::TestCase
|
5
|
-
FIXTURE = API_FIXTURES.fetch(:subscription)
|
6
|
-
|
7
5
|
should "be listable" do
|
8
6
|
subscriptions = Stripe::Subscription.list
|
9
7
|
assert_requested :get, "#{Stripe.api_base}/v1/subscriptions"
|
@@ -12,46 +10,46 @@ module Stripe
|
|
12
10
|
end
|
13
11
|
|
14
12
|
should "be retrievable" do
|
15
|
-
subscription = Stripe::Subscription.retrieve(
|
13
|
+
subscription = Stripe::Subscription.retrieve("sub_123")
|
16
14
|
assert_requested :get,
|
17
|
-
"#{Stripe.api_base}/v1/subscriptions
|
15
|
+
"#{Stripe.api_base}/v1/subscriptions/sub_123"
|
18
16
|
assert subscription.kind_of?(Stripe::Subscription)
|
19
17
|
end
|
20
18
|
|
21
19
|
should "be creatable" do
|
22
20
|
subscription = Stripe::Subscription.create(
|
23
|
-
customer:
|
21
|
+
customer: "cus_123"
|
24
22
|
)
|
25
23
|
assert_requested :post, "#{Stripe.api_base}/v1/subscriptions"
|
26
24
|
assert subscription.kind_of?(Stripe::Subscription)
|
27
25
|
end
|
28
26
|
|
29
27
|
should "be saveable" do
|
30
|
-
subscription = Stripe::Subscription.retrieve(
|
28
|
+
subscription = Stripe::Subscription.retrieve("sub_123")
|
31
29
|
subscription.metadata['key'] = 'value'
|
32
30
|
subscription.save
|
33
31
|
assert_requested :post,
|
34
|
-
"#{Stripe.api_base}/v1/subscriptions/#{
|
32
|
+
"#{Stripe.api_base}/v1/subscriptions/#{subscription.id}"
|
35
33
|
end
|
36
34
|
|
37
35
|
should "be updateable" do
|
38
|
-
subscription = Stripe::Subscription.update(
|
36
|
+
subscription = Stripe::Subscription.update("sub_123", metadata: {foo: 'bar'})
|
39
37
|
assert_requested :post,
|
40
|
-
"#{Stripe.api_base}/v1/subscriptions
|
38
|
+
"#{Stripe.api_base}/v1/subscriptions/sub_123"
|
41
39
|
assert subscription.kind_of?(Stripe::Subscription)
|
42
40
|
end
|
43
41
|
|
44
42
|
should "be deletable" do
|
45
|
-
subscription = Stripe::Subscription.retrieve(
|
43
|
+
subscription = Stripe::Subscription.retrieve("sub_123")
|
46
44
|
subscription = subscription.delete
|
47
45
|
assert_requested :delete,
|
48
|
-
"#{Stripe.api_base}/v1/subscriptions/#{
|
46
|
+
"#{Stripe.api_base}/v1/subscriptions/#{subscription.id}"
|
49
47
|
assert subscription.kind_of?(Stripe::Subscription)
|
50
48
|
end
|
51
49
|
|
52
50
|
context "#delete_discount" do
|
53
51
|
should "be able to delete a subscriptions's discount" do
|
54
|
-
subscription = Stripe::Subscription.retrieve(
|
52
|
+
subscription = Stripe::Subscription.retrieve("sub_123")
|
55
53
|
subscription = subscription.delete_discount
|
56
54
|
assert subscription.kind_of?(Stripe::Subscription)
|
57
55
|
end
|
@@ -2,17 +2,15 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class ThreeDSecureTest < Test::Unit::TestCase
|
5
|
-
FIXTURE = API_FIXTURES.fetch(:three_d_secure)
|
6
|
-
|
7
5
|
should "be retrievable" do
|
8
|
-
secure = Stripe::ThreeDSecure.retrieve(
|
9
|
-
assert_requested :get, "#{Stripe.api_base}/v1/3d_secure
|
6
|
+
secure = Stripe::ThreeDSecure.retrieve("tdsrc_123")
|
7
|
+
assert_requested :get, "#{Stripe.api_base}/v1/3d_secure/tdsrc_123"
|
10
8
|
assert secure.kind_of?(Stripe::ThreeDSecure)
|
11
9
|
end
|
12
10
|
|
13
11
|
should "be creatable" do
|
14
12
|
_ = Stripe::ThreeDSecure.create(
|
15
|
-
card:
|
13
|
+
card: "tok_123",
|
16
14
|
amount: 1500,
|
17
15
|
currency: "usd",
|
18
16
|
return_url: "https://example.org/3d-secure-result"
|
@@ -2,8 +2,6 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class TransferTest < Test::Unit::TestCase
|
5
|
-
FIXTURE = API_FIXTURES.fetch(:transfer)
|
6
|
-
|
7
5
|
should "be listable" do
|
8
6
|
transfers = Stripe::Transfer.list
|
9
7
|
assert_requested :get, "#{Stripe.api_base}/v1/transfers"
|
@@ -12,8 +10,8 @@ module Stripe
|
|
12
10
|
end
|
13
11
|
|
14
12
|
should "be retrievable" do
|
15
|
-
transfer = Stripe::Transfer.retrieve(
|
16
|
-
assert_requested :get, "#{Stripe.api_base}/v1/transfers
|
13
|
+
transfer = Stripe::Transfer.retrieve("tr_123")
|
14
|
+
assert_requested :get, "#{Stripe.api_base}/v1/transfers/tr_123"
|
17
15
|
assert transfer.kind_of?(Stripe::Transfer)
|
18
16
|
end
|
19
17
|
|
@@ -21,22 +19,22 @@ module Stripe
|
|
21
19
|
transfer = Stripe::Transfer.create(
|
22
20
|
amount: 100,
|
23
21
|
currency: "USD",
|
24
|
-
destination:
|
22
|
+
destination: "acct_123"
|
25
23
|
)
|
26
24
|
assert_requested :post, "#{Stripe.api_base}/v1/transfers"
|
27
25
|
assert transfer.kind_of?(Stripe::Transfer)
|
28
26
|
end
|
29
27
|
|
30
28
|
should "be saveable" do
|
31
|
-
transfer = Stripe::Transfer.retrieve(
|
29
|
+
transfer = Stripe::Transfer.retrieve("tr_123")
|
32
30
|
transfer.metadata['key'] = 'value'
|
33
31
|
transfer.save
|
34
|
-
assert_requested :post, "#{Stripe.api_base}/v1/transfers/#{
|
32
|
+
assert_requested :post, "#{Stripe.api_base}/v1/transfers/#{transfer.id}"
|
35
33
|
end
|
36
34
|
|
37
35
|
should "be updateable" do
|
38
|
-
transfer = Stripe::Transfer.update(
|
39
|
-
assert_requested :post, "#{Stripe.api_base}/v1/transfers
|
36
|
+
transfer = Stripe::Transfer.update("tr_123", metadata: {foo: 'bar'})
|
37
|
+
assert_requested :post, "#{Stripe.api_base}/v1/transfers/tr_123"
|
40
38
|
assert transfer.kind_of?(Stripe::Transfer)
|
41
39
|
end
|
42
40
|
end
|
data/test/stripe/util_test.rb
CHANGED
@@ -145,5 +145,169 @@ module Stripe
|
|
145
145
|
should "#array_to_hash should convert an array into a hash with integer keys" do
|
146
146
|
assert_equal({"0" => 1, "1" => 2, "2" => 3}, Util.array_to_hash([1, 2, 3]))
|
147
147
|
end
|
148
|
+
|
149
|
+
context ".request_id_dashboard_url" do
|
150
|
+
should "generate a livemode URL" do
|
151
|
+
assert_equal "https://dashboard.stripe.com/live/logs/request-id",
|
152
|
+
Util.request_id_dashboard_url("request-id", "sk_live_123")
|
153
|
+
end
|
154
|
+
|
155
|
+
should "generate a testmode URL" do
|
156
|
+
assert_equal "https://dashboard.stripe.com/test/logs/request-id",
|
157
|
+
Util.request_id_dashboard_url("request-id", "sk_test_123")
|
158
|
+
end
|
159
|
+
|
160
|
+
should "default to a testmode URL" do
|
161
|
+
assert_equal "https://dashboard.stripe.com/test/logs/request-id",
|
162
|
+
Util.request_id_dashboard_url("request-id", nil)
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
context ".log_*" do
|
167
|
+
setup do
|
168
|
+
@old_log_level = Stripe.log_level
|
169
|
+
Stripe.log_level = nil
|
170
|
+
|
171
|
+
@old_stdout = $stdout
|
172
|
+
$stdout = StringIO.new
|
173
|
+
end
|
174
|
+
|
175
|
+
teardown do
|
176
|
+
Stripe.log_level = @old_log_level
|
177
|
+
$stdout = @old_stdout
|
178
|
+
end
|
179
|
+
|
180
|
+
context ".log_debug" do
|
181
|
+
should "not log if logging is disabled" do
|
182
|
+
Util.log_debug("foo")
|
183
|
+
assert_equal "", $stdout.string
|
184
|
+
end
|
185
|
+
|
186
|
+
should "log if level set to debug" do
|
187
|
+
Stripe.log_level = Stripe::LEVEL_DEBUG
|
188
|
+
Util.log_debug("foo")
|
189
|
+
assert_equal "message=foo level=debug \n", $stdout.string
|
190
|
+
end
|
191
|
+
|
192
|
+
should "not log if level set to info" do
|
193
|
+
Stripe.log_level = Stripe::LEVEL_INFO
|
194
|
+
Util.log_debug("foo")
|
195
|
+
assert_equal "", $stdout.string
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
context ".log_info" do
|
200
|
+
should "not log if logging is disabled" do
|
201
|
+
Util.log_info("foo")
|
202
|
+
assert_equal "", $stdout.string
|
203
|
+
end
|
204
|
+
|
205
|
+
should "log if level set to debug" do
|
206
|
+
Stripe.log_level = Stripe::LEVEL_DEBUG
|
207
|
+
Util.log_info("foo")
|
208
|
+
assert_equal "message=foo level=info \n", $stdout.string
|
209
|
+
end
|
210
|
+
|
211
|
+
should "log if level set to info" do
|
212
|
+
Stripe.log_level = Stripe::LEVEL_INFO
|
213
|
+
Util.log_info("foo")
|
214
|
+
assert_equal "message=foo level=info \n", $stdout.string
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
context ".normalize_headers" do
|
220
|
+
should "normalize the format of a header key" do
|
221
|
+
assert_equal({ "Request-Id" => nil },
|
222
|
+
Util.normalize_headers({ "Request-Id" => nil }))
|
223
|
+
assert_equal({ "Request-Id" => nil },
|
224
|
+
Util.normalize_headers({ "request-id" => nil }))
|
225
|
+
assert_equal({ "Request-Id" => nil },
|
226
|
+
Util.normalize_headers({ "Request-ID" => nil }))
|
227
|
+
assert_equal({ "Request-Id" => nil },
|
228
|
+
Util.normalize_headers({ :request_id => nil }))
|
229
|
+
end
|
230
|
+
|
231
|
+
should "tolerate bad formatting" do
|
232
|
+
assert_equal({ "Request-Id" => nil },
|
233
|
+
Util.normalize_headers({ "-Request--Id-" => nil }))
|
234
|
+
assert_equal({ "Request-Id" => nil },
|
235
|
+
Util.normalize_headers({ :request__id => nil }))
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
#
|
240
|
+
# private
|
241
|
+
#
|
242
|
+
# I don't feel particularly good about using #send to invoke these, but I
|
243
|
+
# want them hidden from the public interface, and each method is far easier
|
244
|
+
# to test in isolation (as opposed to going through a public method).
|
245
|
+
#
|
246
|
+
|
247
|
+
context ".colorize" do
|
248
|
+
should "colorize for a TTY" do
|
249
|
+
assert_equal "\033[0;32;49mfoo\033[0m",
|
250
|
+
Util.send(:colorize, "foo", :green, true)
|
251
|
+
end
|
252
|
+
|
253
|
+
should "not colorize otherwise" do
|
254
|
+
assert_equal "foo", Util.send(:colorize, "foo", :green, false)
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
258
|
+
context ".log_internal" do
|
259
|
+
should "log in a terminal friendly way" do
|
260
|
+
out = StringIO.new
|
261
|
+
|
262
|
+
# Sketchy as anything, but saves us from pulling in a mocking library.
|
263
|
+
# Open this instance of StringIO, and add a method override so that it
|
264
|
+
# looks like a TTY.
|
265
|
+
out.instance_eval do
|
266
|
+
def isatty; true; end
|
267
|
+
end
|
268
|
+
|
269
|
+
Util.send(:log_internal, "message", { foo: "bar" },
|
270
|
+
color: :green, level: Stripe::LEVEL_DEBUG, out: out)
|
271
|
+
assert_equal "\e[0;32;49mDEBU\e[0m message \e[0;32;49mfoo\e[0m=bar\n",
|
272
|
+
out.string
|
273
|
+
end
|
274
|
+
|
275
|
+
should "log in a data friendly way" do
|
276
|
+
out = StringIO.new
|
277
|
+
Util.send(:log_internal, "message", { foo: "bar" },
|
278
|
+
color: :green, level: Stripe::LEVEL_DEBUG, out: out)
|
279
|
+
assert_equal "message=message level=debug foo=bar\n",
|
280
|
+
out.string
|
281
|
+
end
|
282
|
+
end
|
283
|
+
|
284
|
+
context ".wrap_logfmt_value" do
|
285
|
+
should "pass through simple values" do
|
286
|
+
assert_equal "abc", Util.send(:wrap_logfmt_value, "abc")
|
287
|
+
assert_equal "123", Util.send(:wrap_logfmt_value, "123")
|
288
|
+
assert_equal "a-b_c/d", Util.send(:wrap_logfmt_value, "a-b_c/d")
|
289
|
+
end
|
290
|
+
|
291
|
+
should "pass through numerics" do
|
292
|
+
assert_equal 123, Util.send(:wrap_logfmt_value, 123)
|
293
|
+
assert_equal 1.23, Util.send(:wrap_logfmt_value, 1.23)
|
294
|
+
end
|
295
|
+
|
296
|
+
should "wrap more complex values in double quotes" do
|
297
|
+
assert_equal %{"abc=123"}, Util.send(:wrap_logfmt_value, %{abc=123})
|
298
|
+
end
|
299
|
+
|
300
|
+
should "escape double quotes already in the value" do
|
301
|
+
assert_equal %{"abc=\\"123\\""}, Util.send(:wrap_logfmt_value, %{abc="123"})
|
302
|
+
end
|
303
|
+
|
304
|
+
should "remove newlines" do
|
305
|
+
assert_equal %{"abc"}, Util.send(:wrap_logfmt_value, "a\nb\nc")
|
306
|
+
end
|
307
|
+
|
308
|
+
should "not error if given a non-string" do
|
309
|
+
assert_equal "true", Util.send(:wrap_logfmt_value, true)
|
310
|
+
end
|
311
|
+
end
|
148
312
|
end
|
149
313
|
end
|
data/test/test_helper.rb
CHANGED
@@ -1,41 +1,56 @@
|
|
1
|
-
require 'committee'
|
2
|
-
require 'sinatra'
|
3
1
|
require 'stripe'
|
4
2
|
require 'test/unit'
|
5
3
|
require 'mocha/setup'
|
6
4
|
require 'stringio'
|
7
5
|
require 'shoulda/context'
|
6
|
+
require "timecop"
|
8
7
|
require 'webmock/test_unit'
|
9
8
|
|
10
9
|
PROJECT_ROOT = File.expand_path("../../", __FILE__)
|
11
10
|
|
12
|
-
require File.expand_path('../api_fixtures', __FILE__)
|
13
|
-
require File.expand_path('../api_stub_helpers', __FILE__)
|
14
11
|
require File.expand_path('../test_data', __FILE__)
|
15
12
|
|
13
|
+
MOCK_MINIMUM_VERSION = "0.1.12"
|
14
|
+
MOCK_PORT = ENV["STRIPE_MOCK_PORT"] || 12111
|
15
|
+
|
16
|
+
# Disable all real network connections except those that are outgoing to
|
17
|
+
# stripe-mock.
|
18
|
+
WebMock.disable_net_connect!(allow: "localhost:#{MOCK_PORT}")
|
19
|
+
|
20
|
+
# Try one initial test connection to stripe-mock so that if there's a problem
|
21
|
+
# we can print one error and fail fast so that it's more clear to the user how
|
22
|
+
# they should fix the problem.
|
23
|
+
begin
|
24
|
+
resp = Faraday.get("http://localhost:#{MOCK_PORT}/")
|
25
|
+
version = resp.headers['Stripe-Mock-Version']
|
26
|
+
if version != "master" &&
|
27
|
+
Gem::Version.new(version) < Gem::Version.new(MOCK_MINIMUM_VERSION)
|
28
|
+
abort("Your version of stripe-mock (#{version}) is too old. The minimum " \
|
29
|
+
"version to run this test suite is #{MOCK_MINIMUM_VERSION}. Please " \
|
30
|
+
"see its repository for upgrade instructions.")
|
31
|
+
end
|
32
|
+
rescue Faraday::ConnectionFailed
|
33
|
+
abort("Couldn't reach stripe-mock at `localhost:#{MOCK_PORT}`. Is " \
|
34
|
+
"it running? Please see README for setup instructions.")
|
35
|
+
end
|
36
|
+
|
16
37
|
class Test::Unit::TestCase
|
17
|
-
include APIStubHelpers
|
18
38
|
include Stripe::TestData
|
19
39
|
include Mocha
|
20
40
|
|
21
|
-
# Fixtures are available in tests using something like:
|
22
|
-
#
|
23
|
-
# API_FIXTURES[:charge][:id]
|
24
|
-
#
|
25
|
-
API_FIXTURES = APIFixtures.new
|
26
|
-
|
27
41
|
setup do
|
28
|
-
Stripe.api_key = "
|
29
|
-
|
30
|
-
# Stub the Stripe API with a default stub. Note that this method can be
|
31
|
-
# called again in test bodies in order to override responses on particular
|
32
|
-
# endpoints.
|
33
|
-
stub_api
|
34
|
-
|
42
|
+
Stripe.api_key = "sk_test_123"
|
43
|
+
Stripe.api_base = "http://localhost:#{MOCK_PORT}"
|
35
44
|
stub_connect
|
36
45
|
end
|
37
46
|
|
38
47
|
teardown do
|
39
48
|
Stripe.api_key = nil
|
40
49
|
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def stub_connect
|
54
|
+
stub_request(:any, /^#{Stripe.connect_base}/).to_return(:body => "{}")
|
55
|
+
end
|
41
56
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stripe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stripe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-08-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -101,12 +101,7 @@ files:
|
|
101
101
|
- lib/stripe/util.rb
|
102
102
|
- lib/stripe/version.rb
|
103
103
|
- lib/stripe/webhook.rb
|
104
|
-
- openapi/fixtures.json
|
105
|
-
- openapi/fixtures.yaml
|
106
|
-
- openapi/spec2.json
|
107
|
-
- openapi/spec2.yaml
|
108
104
|
- stripe.gemspec
|
109
|
-
- test/api_fixtures.rb
|
110
105
|
- test/api_stub_helpers.rb
|
111
106
|
- test/stripe/account_test.rb
|
112
107
|
- test/stripe/alipay_account_test.rb
|
@@ -182,7 +177,6 @@ signing_key:
|
|
182
177
|
specification_version: 4
|
183
178
|
summary: Ruby bindings for the Stripe API
|
184
179
|
test_files:
|
185
|
-
- test/api_fixtures.rb
|
186
180
|
- test/api_stub_helpers.rb
|
187
181
|
- test/stripe/account_test.rb
|
188
182
|
- test/stripe/alipay_account_test.rb
|