Skip to content

Commit 79d4490

Browse files
authored
Merge pull request #220 from smtlaissezfaire/fix_deprecation_warnings
Fix deprecation warnings + Fix autoload warning
2 parents afc6455 + 383c81e commit 79d4490

File tree

6 files changed

+24
-15
lines changed

6 files changed

+24
-15
lines changed

Changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
## Unreleased
22

3+
- Fix some deprecation warnings in tests. Thanks @smtlaissezfaire !
4+
- Fix `NameError when loading JavascriptHelper`. Thanks @smtlaissezfaire !
5+
36
## 2.3.4 (2022-05-03)
47

58
- Add setup_intent.canceled and setup_intent.requires_action callbacks. Thanks @jamesjason !

lib/stripe/engine.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def stripe_config.api_key=(key)
7979
end
8080
end
8181

82-
initializer 'stripe.javascript_helper' do
82+
config.to_prepare do
8383
ActiveSupport.on_load :action_controller do
8484
# ActionController::API does not have a helper method
8585
if respond_to?(:helper)

test/plan_builder_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@
307307

308308
describe 'when passed invalid arguments for tiered pricing' do
309309
it 'raises a Stripe::InvalidConfigurationError when billing tiers are invalid' do
310-
lambda {
310+
_(lambda {
311311
Stripe.plan "Bad Tiers".to_sym do |plan|
312312
plan.name = 'Acme as a service BAD TIERS'
313313
plan.constant_name = 'BAD_TIERS'
@@ -328,11 +328,11 @@
328328
}
329329
]
330330
end
331-
}.must_raise Stripe::InvalidConfigurationError
331+
}).must_raise Stripe::InvalidConfigurationError
332332
end
333333

334334
it 'raises a Stripe::InvalidConfigurationError when billing tiers is not an array' do
335-
lambda {
335+
_(lambda {
336336
Stripe.plan "Bad Tiers".to_sym do |plan|
337337
plan.name = 'Acme as a service BAD TIERS'
338338
plan.constant_name = 'BAD_TIERS'
@@ -348,7 +348,7 @@
348348
up_to: 10
349349
}
350350
end
351-
}.must_raise Stripe::InvalidConfigurationError
351+
}).must_raise Stripe::InvalidConfigurationError
352352
end
353353
end
354354

test/price_builder_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@
392392

393393
describe 'when passed invalid arguments for tiered pricing' do
394394
it 'raises a Stripe::InvalidConfigurationError when billing tiers are invalid' do
395-
lambda {
395+
_(lambda {
396396
Stripe.price "Bad Tiers".to_sym do |price|
397397
price.name = 'Acme as a service BAD TIERS'
398398
price.constant_name = 'BAD_TIERS'
@@ -414,11 +414,11 @@
414414
}
415415
]
416416
end
417-
}.must_raise Stripe::InvalidConfigurationError
417+
}).must_raise Stripe::InvalidConfigurationError
418418
end
419419

420420
it 'raises a Stripe::InvalidConfigurationError when billing tiers is not an array' do
421-
lambda {
421+
_(lambda {
422422
Stripe.price "Bad Tiers".to_sym do |price|
423423
price.name = 'Acme as a service BAD TIERS'
424424
price.constant_name = 'BAD_TIERS'
@@ -435,7 +435,7 @@
435435
up_to: 10
436436
}
437437
end
438-
}.must_raise Stripe::InvalidConfigurationError
438+
}).must_raise Stripe::InvalidConfigurationError
439439
end
440440
end
441441

test/spec_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@
3434
end
3535

3636
Stripe::Engine.testing = true
37-
require 'mocha/setup'
37+
require 'mocha/minitest'
3838

3939
require 'irb'

test/stripe_initializers_spec.rb

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,18 @@
44
i_suck_and_my_tests_are_order_dependent! # the default test must be run first!
55

66
# NOTE: skipped `stripe.plans_and_coupons` to prevent warnings about constants
7-
STRIPE_INITIALIZER_NAMES = %w{ stripe.configure.defaults stripe.configure stripe.callbacks.eager_load stripe.javascript_helper }
7+
STRIPE_INITIALIZER_NAMES = %w{
8+
stripe.configure.defaults
9+
stripe.configure
10+
stripe.callbacks.eager_load
11+
}
812

913
let(:app) { Rails.application }
1014
let(:initializers) { STRIPE_INITIALIZER_NAMES.map{|name| app.initializers.find{|ini| ini.name == name } } }
1115

12-
def rerun_initializers!; initializers.each{|init| init.run(app) }; end
16+
def rerun_initializers!
17+
initializers.each { |init| init.run(app) }
18+
end
1319

1420
after do
1521
Stripe.api_version = nil
@@ -60,11 +66,11 @@ def rerun_initializers!; initializers.each{|init| init.run(app) }; end
6066
it "supports nil signing_secret" do
6167
subject
6268

63-
app.config.stripe.signing_secret = nil
69+
app.config.stripe.signing_secret = nil
6470
rerun_initializers!
6571

66-
_(app.config.stripe.signing_secret).must_equal nil
67-
_(app.config.stripe.signing_secrets).must_equal nil
72+
assert_nil app.config.stripe.signing_secret
73+
assert_nil app.config.stripe.signing_secrets
6874
end
6975

7076
it "supports multiple signing secrets" do

0 commit comments

Comments
 (0)