stripe 5.27.0 → 5.31.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -16,19 +16,23 @@ module Stripe
16
16
  assert_equal 0, config.max_network_retries
17
17
  assert_equal 30, config.open_timeout
18
18
  assert_equal 80, config.read_timeout
19
+ assert_equal 30, config.write_timeout
19
20
  assert_equal "https://api.stripe.com", config.api_base
20
21
  assert_equal "https://connect.stripe.com", config.connect_base
21
22
  assert_equal "https://files.stripe.com", config.uploads_base
23
+ assert_equal nil, config.api_version
22
24
  end
23
25
 
24
26
  should "allow for overrides when a block is passed" do
25
27
  config = Stripe::StripeConfiguration.setup do |c|
26
28
  c.open_timeout = 100
27
29
  c.read_timeout = 100
30
+ c.write_timeout = 100 if WRITE_TIMEOUT_SUPPORTED
28
31
  end
29
32
 
30
33
  assert_equal 100, config.open_timeout
31
34
  assert_equal 100, config.read_timeout
35
+ assert_equal 100, config.write_timeout if WRITE_TIMEOUT_SUPPORTED
32
36
  end
33
37
  end
34
38
 
@@ -38,7 +42,7 @@ module Stripe
38
42
  c.open_timeout = 100
39
43
  end
40
44
 
41
- duped_config = config.reverse_duplicate_merge(read_timeout: 500)
45
+ duped_config = config.reverse_duplicate_merge(read_timeout: 500, api_version: "2018-08-02")
42
46
 
43
47
  assert_equal config.open_timeout, duped_config.open_timeout
44
48
  assert_equal 500, duped_config.read_timeout
@@ -54,6 +58,24 @@ module Stripe
54
58
  end
55
59
  end
56
60
 
61
+ context "#max_network_retry_delay=" do
62
+ should "coerce the option into an integer" do
63
+ config = Stripe::StripeConfiguration.setup
64
+
65
+ config.max_network_retry_delay = "10"
66
+ assert_equal 10, config.max_network_retry_delay
67
+ end
68
+ end
69
+
70
+ context "#initial_network_retry_delay=" do
71
+ should "coerce the option into an integer" do
72
+ config = Stripe::StripeConfiguration.setup
73
+
74
+ config.initial_network_retry_delay = "10"
75
+ assert_equal 10, config.initial_network_retry_delay
76
+ end
77
+ end
78
+
57
79
  context "#log_level=" do
58
80
  should "be backwards compatible with old values" do
59
81
  config = Stripe::StripeConfiguration.setup
@@ -78,51 +100,60 @@ module Stripe
78
100
  should "clear when setting allow ca_bundle_path" do
79
101
  config = Stripe::StripeConfiguration.setup
80
102
 
81
- StripeClient.expects(:clear_all_connection_managers)
103
+ StripeClient.expects(:clear_all_connection_managers).with(config: config)
82
104
  config.ca_bundle_path = "/path/to/ca/bundle"
83
105
  end
84
106
 
85
107
  should "clear when setting open timeout" do
86
108
  config = Stripe::StripeConfiguration.setup
87
109
 
88
- StripeClient.expects(:clear_all_connection_managers)
110
+ StripeClient.expects(:clear_all_connection_managers).with(config: config)
89
111
  config.open_timeout = 10
90
112
  end
91
113
 
92
114
  should "clear when setting read timeout" do
93
115
  config = Stripe::StripeConfiguration.setup
94
116
 
95
- StripeClient.expects(:clear_all_connection_managers)
117
+ StripeClient.expects(:clear_all_connection_managers).with(config: config)
96
118
  config.read_timeout = 10
97
119
  end
98
120
 
99
121
  should "clear when setting uploads_base" do
100
122
  config = Stripe::StripeConfiguration.setup
101
123
 
102
- StripeClient.expects(:clear_all_connection_managers)
124
+ StripeClient.expects(:clear_all_connection_managers).with(config: config)
103
125
  config.uploads_base = "https://other.stripe.com"
104
126
  end
105
127
 
106
- should "clearn when setting api_base to be configured" do
128
+ should "clear when setting api_base to be configured" do
107
129
  config = Stripe::StripeConfiguration.setup
108
130
 
109
- StripeClient.expects(:clear_all_connection_managers)
131
+ StripeClient.expects(:clear_all_connection_managers).with(config: config)
110
132
  config.api_base = "https://other.stripe.com"
111
133
  end
112
134
 
113
135
  should "clear when setting connect_base" do
114
136
  config = Stripe::StripeConfiguration.setup
115
137
 
116
- StripeClient.expects(:clear_all_connection_managers)
138
+ StripeClient.expects(:clear_all_connection_managers).with(config: config)
117
139
  config.connect_base = "https://other.stripe.com"
118
140
  end
119
141
 
120
142
  should "clear when setting verify_ssl_certs" do
121
143
  config = Stripe::StripeConfiguration.setup
122
144
 
123
- StripeClient.expects(:clear_all_connection_managers)
145
+ StripeClient.expects(:clear_all_connection_managers).with(config: config)
124
146
  config.verify_ssl_certs = false
125
147
  end
126
148
  end
149
+
150
+ context "#key" do
151
+ should "generate the same key when values are identicial" do
152
+ assert_equal StripeConfiguration.setup.key, StripeConfiguration.setup.key
153
+
154
+ custom_config = StripeConfiguration.setup { |c| c.open_timeout = 1000 }
155
+ refute_equal StripeConfiguration.setup.key, custom_config.key
156
+ end
157
+ end
127
158
  end
128
159
  end
@@ -496,5 +496,15 @@ module Stripe
496
496
  assert obj.method(:id).is_a?(Method)
497
497
  end
498
498
  end
499
+
500
+ should "ignore properties that are reserved names" do
501
+ obj = Stripe::StripeObject.construct_from(metadata: { class: "something" })
502
+
503
+ # See comment on `StripeObject::RESERVED_FIELD_NAMES`
504
+ assert_equal Stripe::StripeObject, obj.metadata.class
505
+
506
+ # Value still accessible with hash syntax
507
+ assert_equal "something", obj.metadata[:class]
508
+ end
499
509
  end
500
510
  end
data/test/stripe_test.rb CHANGED
@@ -54,6 +54,19 @@ class StripeTest < Test::Unit::TestCase
54
54
  assert_equal 10, Stripe.read_timeout
55
55
  end
56
56
 
57
+ if WRITE_TIMEOUT_SUPPORTED
58
+ should "allow write timeout to be configured" do
59
+ Stripe.write_timeout = 10
60
+ assert_equal 10, Stripe.write_timeout
61
+ end
62
+ else
63
+ should "raise when write timeout to be configured is not supported" do
64
+ assert_raises NotImplementedError do
65
+ Stripe.write_timeout = 10
66
+ end
67
+ end
68
+ end
69
+
57
70
  should "allow api_key to be configured" do
58
71
  Stripe.api_key = "sk_local_test"
59
72
  assert_equal "sk_local_test", Stripe.api_key
@@ -101,6 +114,11 @@ class StripeTest < Test::Unit::TestCase
101
114
  assert_equal "https://other.stripe.com", Stripe.api_base
102
115
  end
103
116
 
117
+ should "allow api_version to be configured" do
118
+ Stripe.api_version = "2018-02-28"
119
+ assert_equal "2018-02-28", Stripe.api_version
120
+ end
121
+
104
122
  should "allow connect_base to be configured" do
105
123
  Stripe.connect_base = "https://other.stripe.com"
106
124
  assert_equal "https://other.stripe.com", Stripe.connect_base
data/test/test_helper.rb CHANGED
@@ -1,8 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "coveralls"
4
- Coveralls.wear!("test_frameworks")
5
-
6
3
  require "stripe"
7
4
  require "test/unit"
8
5
  require "mocha/setup"
@@ -16,7 +13,7 @@ require ::File.expand_path("test_data", __dir__)
16
13
  require ::File.expand_path("stripe_mock", __dir__)
17
14
 
18
15
  # If changing this number, please also change it in `.travis.yml`.
19
- MOCK_MINIMUM_VERSION = "0.101.0"
16
+ MOCK_MINIMUM_VERSION = "0.103.0"
20
17
  MOCK_PORT = Stripe::StripeMock.start
21
18
 
22
19
  # Disable all real network connections except those that are outgoing to
@@ -56,6 +53,8 @@ module Test
56
53
  include Stripe::TestData
57
54
  include Mocha
58
55
 
56
+ WRITE_TIMEOUT_SUPPORTED = Net::HTTP.instance_methods.include?(:write_timeout=)
57
+
59
58
  setup do
60
59
  Stripe.api_key = "sk_test_123"
61
60
  Stripe.api_base = "http://localhost:#{MOCK_PORT}"
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: 5.27.0
4
+ version: 5.31.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stripe
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-14 00:00:00.000000000 Z
11
+ date: 2021-04-02 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Stripe is the easiest way to accept payments online. See https://stripe.com
14
14
  for details.
@@ -21,6 +21,7 @@ files:
21
21
  - ".editorconfig"
22
22
  - ".gitattributes"
23
23
  - ".github/ISSUE_TEMPLATE.md"
24
+ - ".github/workflows/ci.yml"
24
25
  - ".gitignore"
25
26
  - ".rubocop.yml"
26
27
  - ".rubocop_todo.yml"
@@ -64,6 +65,7 @@ files:
64
65
  - lib/stripe/resources/balance.rb
65
66
  - lib/stripe/resources/balance_transaction.rb
66
67
  - lib/stripe/resources/bank_account.rb
68
+ - lib/stripe/resources/billing_portal/configuration.rb
67
69
  - lib/stripe/resources/billing_portal/session.rb
68
70
  - lib/stripe/resources/bitcoin_receiver.rb
69
71
  - lib/stripe/resources/bitcoin_transaction.rb
@@ -158,6 +160,7 @@ files:
158
160
  - test/stripe/balance_test.rb
159
161
  - test/stripe/balance_transaction_test.rb
160
162
  - test/stripe/bank_account_test.rb
163
+ - test/stripe/billing_portal/configuration_test.rb
161
164
  - test/stripe/billing_portal/session_test.rb
162
165
  - test/stripe/capability_test.rb
163
166
  - test/stripe/charge_test.rb
@@ -246,7 +249,7 @@ metadata:
246
249
  github_repo: ssh://github.com/stripe/stripe-ruby
247
250
  homepage_uri: https://stripe.com/docs/api/ruby
248
251
  source_code_uri: https://github.com/stripe/stripe-ruby
249
- post_install_message:
252
+ post_install_message:
250
253
  rdoc_options: []
251
254
  require_paths:
252
255
  - lib
@@ -262,7 +265,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
262
265
  version: '0'
263
266
  requirements: []
264
267
  rubygems_version: 3.1.2
265
- signing_key:
268
+ signing_key:
266
269
  specification_version: 4
267
270
  summary: Ruby bindings for the Stripe API
268
271
  test_files:
@@ -278,6 +281,7 @@ test_files:
278
281
  - test/stripe/balance_test.rb
279
282
  - test/stripe/balance_transaction_test.rb
280
283
  - test/stripe/bank_account_test.rb
284
+ - test/stripe/billing_portal/configuration_test.rb
281
285
  - test/stripe/billing_portal/session_test.rb
282
286
  - test/stripe/capability_test.rb
283
287
  - test/stripe/charge_test.rb