stripe-rails 1.9.1 → 2.0.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/ruby.yml +10 -6
- data/Changelog.md +26 -0
- data/Gemfile +4 -4
- data/README.md +19 -2
- data/gemfiles/{rails4.gemfile → rails51.gemfile} +6 -5
- data/gemfiles/rails52.gemfile +20 -0
- data/lib/generators/templates/products.rb +2 -2
- data/lib/stripe/billing_tier.rb +34 -0
- data/lib/stripe/callbacks.rb +3 -4
- data/lib/stripe/plans.rb +33 -5
- data/lib/stripe/products.rb +2 -0
- data/lib/stripe/rails.rb +1 -0
- data/lib/stripe/rails/version.rb +1 -1
- data/stripe-rails.gemspec +2 -2
- data/test/callbacks_spec.rb +15 -15
- data/test/coupon_builder_spec.rb +4 -4
- data/test/dummy/config/stripe/plans.rb +21 -0
- data/test/dummy_apis_controller_spec.rb +1 -1
- data/test/events_controller_spec.rb +5 -5
- data/test/javascript_helper_spec.rb +12 -12
- data/test/plan_builder_spec.rb +112 -36
- data/test/product_builder_spec.rb +11 -11
- data/test/stripe_initializers_spec.rb +23 -23
- data/test/support/application_system_test_case.rb +2 -7
- data/test/testing_spec.rb +8 -8
- metadata +13 -17
- data/app/controllers/stripe/pings_controller.rb +0 -10
- data/app/models/stripe/ping.rb +0 -9
- data/test/pings_controller_spec.rb +0 -18
- data/test/support/null_system_test_case.rb +0 -11
data/test/coupon_builder_spec.rb
CHANGED
@@ -13,7 +13,7 @@ describe 'building coupons' do
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
it "allows a single redemption by default" do
|
16
|
-
@coupon.max_redemptions.must_equal 1
|
16
|
+
_(@coupon.max_redemptions).must_equal 1
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -33,8 +33,8 @@ describe 'building coupons' do
|
|
33
33
|
after {Stripe::Coupons.send(:remove_const, :GOLD25)}
|
34
34
|
|
35
35
|
it 'is accessible via hash lookup (symbol/string agnostic)' do
|
36
|
-
Stripe::Coupons[:gold25].must_equal Stripe::Coupons::GOLD25
|
37
|
-
Stripe::Coupons['gold25'].must_equal Stripe::Coupons::GOLD25
|
36
|
+
_(Stripe::Coupons[:gold25]).must_equal Stripe::Coupons::GOLD25
|
37
|
+
_(Stripe::Coupons['gold25']).must_equal Stripe::Coupons::GOLD25
|
38
38
|
end
|
39
39
|
|
40
40
|
describe 'uploading' do
|
@@ -116,7 +116,7 @@ describe 'building coupons' do
|
|
116
116
|
end
|
117
117
|
describe 'with missing mandatory values' do
|
118
118
|
it 'raises an exception after configuring it' do
|
119
|
-
proc {Stripe.coupon(:bad) {}}.must_raise Stripe::InvalidConfigurationError
|
119
|
+
_(proc {Stripe.coupon(:bad) {}}).must_raise Stripe::InvalidConfigurationError
|
120
120
|
end
|
121
121
|
end
|
122
122
|
end
|
@@ -26,3 +26,24 @@ Stripe.plan :metered do |plan|
|
|
26
26
|
plan.aggregate_usage = 'max'
|
27
27
|
plan.billing_scheme = 'per_unit'
|
28
28
|
end
|
29
|
+
|
30
|
+
Stripe.plan :tiered do |plan|
|
31
|
+
plan.name = 'Tiered'
|
32
|
+
plan.aggregate_usage = 'max'
|
33
|
+
plan.billing_scheme = 'tiered'
|
34
|
+
# interval must be either 'day', 'week', 'month' or 'year'
|
35
|
+
plan.interval = 'month'
|
36
|
+
plan.interval_count = 1
|
37
|
+
plan.tiers = [
|
38
|
+
{
|
39
|
+
unit_amount: 1500,
|
40
|
+
up_to: 10
|
41
|
+
},
|
42
|
+
{
|
43
|
+
unit_amount: 1000,
|
44
|
+
up_to: 'inf'
|
45
|
+
}
|
46
|
+
]
|
47
|
+
plan.tiers_mode = 'graduated'
|
48
|
+
plan.usage_type = 'metered'
|
49
|
+
end
|
@@ -24,7 +24,7 @@ describe Stripe::EventsController do
|
|
24
24
|
end
|
25
25
|
subject { post '/stripe/events', params.to_json }
|
26
26
|
|
27
|
-
it { subject.must_be :ok? }
|
27
|
+
it { _(subject).must_be :ok? }
|
28
28
|
end
|
29
29
|
|
30
30
|
describe 'signed webhooks' do
|
@@ -50,12 +50,12 @@ describe Stripe::EventsController do
|
|
50
50
|
|
51
51
|
it 'returns bad_request when invalid' do
|
52
52
|
Stripe::Webhook.expects(:construct_event).raises(Stripe::SignatureVerificationError.new('msg', 'sig_header'))
|
53
|
-
subject.must_be :bad_request?
|
53
|
+
_(subject).must_be :bad_request?
|
54
54
|
end
|
55
55
|
|
56
56
|
it 'returns ok when valid' do
|
57
57
|
Stripe::Webhook.expects(:construct_event).returns(Stripe::Event.construct_from(params))
|
58
|
-
subject.must_be :ok?
|
58
|
+
_(subject).must_be :ok?
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
@@ -82,12 +82,12 @@ describe Stripe::EventsController do
|
|
82
82
|
|
83
83
|
it 'returns bad_request when invalid' do
|
84
84
|
Stripe::Webhook.expects(:construct_event).twice.raises(Stripe::SignatureVerificationError.new('msg', 'sig_header'))
|
85
|
-
subject.must_be :bad_request?
|
85
|
+
_(subject).must_be :bad_request?
|
86
86
|
end
|
87
87
|
|
88
88
|
it 'returns ok when valid' do
|
89
89
|
Stripe::Webhook.expects(:construct_event).returns(Stripe::Event.construct_from(params))
|
90
|
-
subject.must_be :ok?
|
90
|
+
_(subject).must_be :ok?
|
91
91
|
end
|
92
92
|
end
|
93
93
|
end
|
@@ -8,13 +8,13 @@ describe Stripe::JavascriptHelper do
|
|
8
8
|
describe '#stripe_javascript_tag' do
|
9
9
|
describe 'when no options are passed' do
|
10
10
|
it 'should default to v3' do
|
11
|
-
view.stripe_javascript_tag.must_include 'https://js.stripe.com/v3/'
|
11
|
+
_(view.stripe_javascript_tag).must_include 'https://js.stripe.com/v3/'
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
15
|
describe 'when the v2 option is passed' do
|
16
16
|
it 'should default to v2' do
|
17
|
-
view.stripe_javascript_tag(:v2).must_include 'https://js.stripe.com/v2/'
|
17
|
+
_(view.stripe_javascript_tag(:v2)).must_include 'https://js.stripe.com/v2/'
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -22,12 +22,12 @@ describe Stripe::JavascriptHelper do
|
|
22
22
|
before { Rails.application.config.stripe.debug_js = true }
|
23
23
|
after { Rails.application.config.stripe.debug_js = false }
|
24
24
|
it 'should render the debug js' do
|
25
|
-
view.stripe_javascript_tag(:v1).must_include 'https://js.stripe.com/v1/stripe-debug.js'
|
25
|
+
_(view.stripe_javascript_tag(:v1)).must_include 'https://js.stripe.com/v1/stripe-debug.js'
|
26
26
|
end
|
27
27
|
|
28
28
|
describe 'when v3 is selected' do
|
29
29
|
it 'should not render debug js' do
|
30
|
-
view.stripe_javascript_tag(:v3).wont_include 'https://js.stripe.com/v1/stripe-debug.js'
|
30
|
+
_(view.stripe_javascript_tag(:v3)).wont_include 'https://js.stripe.com/v1/stripe-debug.js'
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
@@ -37,7 +37,7 @@ describe Stripe::JavascriptHelper do
|
|
37
37
|
subject { view.render :partial => 'stripe/js' }
|
38
38
|
|
39
39
|
it 'should render correctly' do
|
40
|
-
subject.must_include 'https://js.stripe.com/v3/'
|
40
|
+
_(subject).must_include 'https://js.stripe.com/v3/'
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
@@ -45,35 +45,35 @@ describe Stripe::JavascriptHelper do
|
|
45
45
|
subject { view.render :partial => 'stripe/js', locals: {stripe_js_version: 'v2'} }
|
46
46
|
|
47
47
|
it 'should render correctly' do
|
48
|
-
subject.must_include 'https://js.stripe.com/v2/'
|
48
|
+
_(subject).must_include 'https://js.stripe.com/v2/'
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
52
|
describe '#stripe_elements_tag' do
|
53
53
|
describe 'when no options are passed' do
|
54
54
|
it 'should display the form' do
|
55
|
-
view.stripe_elements_tag(
|
55
|
+
_(view.stripe_elements_tag(
|
56
56
|
submit_path: '/charge',
|
57
|
-
).must_include 'Credit or debit card'
|
57
|
+
)).must_include 'Credit or debit card'
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
61
|
describe 'with options' do
|
62
62
|
describe 'without default js' do
|
63
63
|
it 'wont include the default script tag' do
|
64
|
-
view.stripe_elements_tag(
|
64
|
+
_(view.stripe_elements_tag(
|
65
65
|
submit_path: '/charge',
|
66
66
|
js_path: 'another/path'
|
67
|
-
).wont_include '<script id="stripe_elements_js">'
|
67
|
+
)).wont_include '<script id="stripe_elements_js">'
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
71
|
describe 'without default css' do
|
72
72
|
it 'wont include the default style tag' do
|
73
|
-
view.stripe_elements_tag(
|
73
|
+
_(view.stripe_elements_tag(
|
74
74
|
submit_path: '/charge',
|
75
75
|
css_path: 'another/path'
|
76
|
-
).wont_include '<style>'
|
76
|
+
)).wont_include '<style>'
|
77
77
|
end
|
78
78
|
end
|
79
79
|
end
|
data/test/plan_builder_spec.rb
CHANGED
@@ -23,16 +23,16 @@ describe 'building plans' do
|
|
23
23
|
after { Stripe::Plans.send(:remove_const, :PRIMO) }
|
24
24
|
|
25
25
|
it 'is accessible via id' do
|
26
|
-
Stripe::Plans::PRIMO.wont_be_nil
|
26
|
+
_(Stripe::Plans::PRIMO).wont_be_nil
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'is accessible via collection' do
|
30
|
-
Stripe::Plans.all.must_include Stripe::Plans::PRIMO
|
30
|
+
_(Stripe::Plans.all).must_include Stripe::Plans::PRIMO
|
31
31
|
end
|
32
32
|
|
33
33
|
it 'is accessible via hash lookup (symbol/string agnostic)' do
|
34
|
-
Stripe::Plans[:primo].must_equal Stripe::Plans::PRIMO
|
35
|
-
Stripe::Plans['primo'].must_equal Stripe::Plans::PRIMO
|
34
|
+
_(Stripe::Plans[:primo]).must_equal Stripe::Plans::PRIMO
|
35
|
+
_(Stripe::Plans['primo']).must_equal Stripe::Plans::PRIMO
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'accepts a billing interval of a day' do
|
@@ -42,7 +42,7 @@ describe 'building plans' do
|
|
42
42
|
plan.interval = 'day'
|
43
43
|
end
|
44
44
|
|
45
|
-
Stripe::Plans::DAILY.wont_be_nil
|
45
|
+
_(Stripe::Plans::DAILY).wont_be_nil
|
46
46
|
end
|
47
47
|
|
48
48
|
it 'accepts a billing interval of a week' do
|
@@ -52,7 +52,7 @@ describe 'building plans' do
|
|
52
52
|
plan.interval = 'week'
|
53
53
|
end
|
54
54
|
|
55
|
-
Stripe::Plans::WEEKLY.wont_be_nil
|
55
|
+
_(Stripe::Plans::WEEKLY).wont_be_nil
|
56
56
|
end
|
57
57
|
|
58
58
|
it 'accepts a billing interval of a month' do
|
@@ -62,7 +62,7 @@ describe 'building plans' do
|
|
62
62
|
plan.interval = 'month'
|
63
63
|
end
|
64
64
|
|
65
|
-
Stripe::Plans::MONTHLY.wont_be_nil
|
65
|
+
_(Stripe::Plans::MONTHLY).wont_be_nil
|
66
66
|
end
|
67
67
|
|
68
68
|
it 'accepts a billing interval of a year' do
|
@@ -72,17 +72,17 @@ describe 'building plans' do
|
|
72
72
|
plan.interval = 'year'
|
73
73
|
end
|
74
74
|
|
75
|
-
Stripe::Plans::YEARLY.wont_be_nil
|
75
|
+
_(Stripe::Plans::YEARLY).wont_be_nil
|
76
76
|
end
|
77
77
|
|
78
78
|
it 'denies arbitrary billing intervals' do
|
79
|
-
lambda {
|
79
|
+
_(lambda {
|
80
80
|
Stripe.plan :broken do |plan|
|
81
81
|
plan.name = 'Acme as a service BROKEN'
|
82
82
|
plan.amount = 999
|
83
83
|
plan.interval = 'anything'
|
84
84
|
end
|
85
|
-
}.must_raise Stripe::InvalidConfigurationError
|
85
|
+
}).must_raise Stripe::InvalidConfigurationError
|
86
86
|
end
|
87
87
|
|
88
88
|
it 'accepts a statement descriptor' do
|
@@ -93,55 +93,55 @@ describe 'building plans' do
|
|
93
93
|
plan.statement_descriptor = 'ACME Monthly'
|
94
94
|
end
|
95
95
|
|
96
|
-
Stripe::Plans::DESCRIBED.wont_be_nil
|
96
|
+
_(Stripe::Plans::DESCRIBED).wont_be_nil
|
97
97
|
end
|
98
98
|
|
99
99
|
it 'denies statement descriptors that are too long' do
|
100
|
-
lambda {
|
100
|
+
_(lambda {
|
101
101
|
Stripe.plan :described do |plan|
|
102
102
|
plan.name = 'Acme as a service'
|
103
103
|
plan.amount = 999
|
104
104
|
plan.interval = 'month'
|
105
105
|
plan.statement_descriptor = 'ACME as a Service Monthly'
|
106
106
|
end
|
107
|
-
}.must_raise Stripe::InvalidConfigurationError
|
107
|
+
}).must_raise Stripe::InvalidConfigurationError
|
108
108
|
end
|
109
109
|
|
110
110
|
it 'denies invalid values for active' do
|
111
|
-
lambda {
|
111
|
+
_(lambda {
|
112
112
|
Stripe.plan :broken do |plan|
|
113
113
|
plan.name = 'Acme as a service'
|
114
114
|
plan.amount = 999
|
115
115
|
plan.interval = 'month'
|
116
116
|
plan.active = 'whatever'
|
117
117
|
end
|
118
|
-
}.must_raise Stripe::InvalidConfigurationError
|
118
|
+
}).must_raise Stripe::InvalidConfigurationError
|
119
119
|
end
|
120
120
|
|
121
121
|
it 'denies invalid values for usage_type' do
|
122
|
-
lambda {
|
122
|
+
_(lambda {
|
123
123
|
Stripe.plan :broken do |plan|
|
124
124
|
plan.name = 'Acme as a service'
|
125
125
|
plan.amount = 999
|
126
126
|
plan.interval = 'month'
|
127
127
|
plan.usage_type = 'whatever'
|
128
128
|
end
|
129
|
-
}.must_raise Stripe::InvalidConfigurationError
|
129
|
+
}).must_raise Stripe::InvalidConfigurationError
|
130
130
|
end
|
131
131
|
|
132
132
|
it 'denies invalid values for aggregate_usage' do
|
133
|
-
lambda {
|
133
|
+
_(lambda {
|
134
134
|
Stripe.plan :broken do |plan|
|
135
135
|
plan.name = 'Acme as a service'
|
136
136
|
plan.amount = 999
|
137
137
|
plan.interval = 'month'
|
138
138
|
plan.aggregate_usage = 'whatever'
|
139
139
|
end
|
140
|
-
}.must_raise Stripe::InvalidConfigurationError
|
140
|
+
}).must_raise Stripe::InvalidConfigurationError
|
141
141
|
end
|
142
142
|
|
143
143
|
it 'denies aggregate_usage if usage type is liecensed' do
|
144
|
-
lambda {
|
144
|
+
_(lambda {
|
145
145
|
Stripe.plan :broken do |plan|
|
146
146
|
plan.name = 'Acme as a service'
|
147
147
|
plan.amount = 999
|
@@ -149,30 +149,30 @@ describe 'building plans' do
|
|
149
149
|
plan.usage_type = 'licensed'
|
150
150
|
plan.aggregate_usage = 'sum'
|
151
151
|
end
|
152
|
-
}.must_raise Stripe::InvalidConfigurationError
|
152
|
+
}).must_raise Stripe::InvalidConfigurationError
|
153
153
|
end
|
154
154
|
|
155
155
|
|
156
156
|
it 'denies invalid values for billing_scheme' do
|
157
|
-
lambda {
|
157
|
+
_(lambda {
|
158
158
|
Stripe.plan :broken do |plan|
|
159
159
|
plan.name = 'Acme as a service'
|
160
160
|
plan.amount = 999
|
161
161
|
plan.interval = 'month'
|
162
162
|
plan.billing_scheme = 'whatever'
|
163
163
|
end
|
164
|
-
}.must_raise Stripe::InvalidConfigurationError
|
164
|
+
}).must_raise Stripe::InvalidConfigurationError
|
165
165
|
end
|
166
166
|
|
167
167
|
it 'denies invalid values for tiers_mode' do
|
168
|
-
lambda {
|
168
|
+
_(lambda {
|
169
169
|
Stripe.plan :broken do |plan|
|
170
170
|
plan.name = 'Acme as a service'
|
171
171
|
plan.amount = 999
|
172
172
|
plan.interval = 'month'
|
173
173
|
plan.tiers_mode = 'whatever'
|
174
174
|
end
|
175
|
-
}.must_raise Stripe::InvalidConfigurationError
|
175
|
+
}).must_raise Stripe::InvalidConfigurationError
|
176
176
|
end
|
177
177
|
|
178
178
|
describe 'name and product id validation' do
|
@@ -182,18 +182,18 @@ describe 'building plans' do
|
|
182
182
|
plan.amount = 999
|
183
183
|
plan.interval = 'month'
|
184
184
|
end
|
185
|
-
Stripe::Plans::PRODDED.wont_be_nil
|
185
|
+
_(Stripe::Plans::PRODDED).wont_be_nil
|
186
186
|
end
|
187
187
|
|
188
188
|
it 'should be invalid when using both name and product id' do
|
189
|
-
lambda {
|
189
|
+
_(lambda {
|
190
190
|
Stripe.plan :broken do |plan|
|
191
191
|
plan.name = 'Acme as a service'
|
192
192
|
plan.product_id = 'acme'
|
193
193
|
plan.amount = 999
|
194
194
|
plan.interval = 'month'
|
195
195
|
end
|
196
|
-
}.must_raise Stripe::InvalidConfigurationError
|
196
|
+
}).must_raise Stripe::InvalidConfigurationError
|
197
197
|
end
|
198
198
|
end
|
199
199
|
|
@@ -275,6 +275,82 @@ describe 'building plans' do
|
|
275
275
|
Stripe::Plans::METERED.put!
|
276
276
|
end
|
277
277
|
|
278
|
+
it 'creates a tiered plan' do
|
279
|
+
Stripe::Plan.expects(:create).with(
|
280
|
+
:id => :tiered,
|
281
|
+
:currency => 'usd',
|
282
|
+
:product => {
|
283
|
+
:name => 'Tiered',
|
284
|
+
:statement_descriptor => nil,
|
285
|
+
},
|
286
|
+
:interval => 'month',
|
287
|
+
:interval_count => 1,
|
288
|
+
:trial_period_days => 0,
|
289
|
+
:usage_type => 'metered',
|
290
|
+
:aggregate_usage => 'max',
|
291
|
+
:billing_scheme => 'tiered',
|
292
|
+
:tiers => [
|
293
|
+
{
|
294
|
+
:unit_amount => 1500,
|
295
|
+
:up_to => 10
|
296
|
+
},
|
297
|
+
{
|
298
|
+
:unit_amount => 1000,
|
299
|
+
:up_to => 'inf'
|
300
|
+
}
|
301
|
+
],
|
302
|
+
:tiers_mode => 'graduated'
|
303
|
+
)
|
304
|
+
plan = Stripe::Plans::TIERED
|
305
|
+
Stripe::Plans::TIERED.put!
|
306
|
+
end
|
307
|
+
|
308
|
+
describe 'when passed invalid arguments for tiered pricing' do
|
309
|
+
it 'raises a Stripe::InvalidConfigurationError when billing tiers are invalid' do
|
310
|
+
lambda {
|
311
|
+
Stripe.plan "Bad Tiers".to_sym do |plan|
|
312
|
+
plan.name = 'Acme as a service BAD TIERS'
|
313
|
+
plan.constant_name = 'BAD_TIERS'
|
314
|
+
plan.interval = 'month'
|
315
|
+
plan.interval_count = 1
|
316
|
+
plan.trial_period_days = 30
|
317
|
+
plan.usage_type = 'metered'
|
318
|
+
plan.tiers_mode = 'graduated'
|
319
|
+
plan.billing_scheme = 'per_unit'
|
320
|
+
plan.aggregate_usage = 'sum'
|
321
|
+
plan.tiers = [
|
322
|
+
{
|
323
|
+
unit_amount: 1500,
|
324
|
+
up_to: 10
|
325
|
+
},
|
326
|
+
{
|
327
|
+
unit_amount: 1000,
|
328
|
+
}
|
329
|
+
]
|
330
|
+
end
|
331
|
+
}.must_raise Stripe::InvalidConfigurationError
|
332
|
+
end
|
333
|
+
|
334
|
+
it 'raises a Stripe::InvalidConfigurationError when billing tiers is not an array' do
|
335
|
+
lambda {
|
336
|
+
Stripe.plan "Bad Tiers".to_sym do |plan|
|
337
|
+
plan.name = 'Acme as a service BAD TIERS'
|
338
|
+
plan.constant_name = 'BAD_TIERS'
|
339
|
+
plan.interval = 'month'
|
340
|
+
plan.interval_count = 1
|
341
|
+
plan.trial_period_days = 30
|
342
|
+
plan.usage_type = 'metered'
|
343
|
+
plan.tiers_mode = 'graduated'
|
344
|
+
plan.billing_scheme = 'per_unit'
|
345
|
+
plan.aggregate_usage = 'sum'
|
346
|
+
plan.tiers = {
|
347
|
+
unit_amount: 1500,
|
348
|
+
up_to: 10
|
349
|
+
}
|
350
|
+
end
|
351
|
+
}.must_raise Stripe::InvalidConfigurationError
|
352
|
+
end
|
353
|
+
end
|
278
354
|
|
279
355
|
describe 'when using a product id' do
|
280
356
|
before do
|
@@ -343,10 +419,10 @@ describe 'building plans' do
|
|
343
419
|
|
344
420
|
describe 'with missing mandatory values' do
|
345
421
|
it 'raises an exception after configuring it' do
|
346
|
-
|
422
|
+
_(-> { Stripe.plan(:bad) {} }).must_raise Stripe::InvalidConfigurationError
|
347
423
|
end
|
348
424
|
end
|
349
|
-
|
425
|
+
|
350
426
|
describe 'with custom constant name' do
|
351
427
|
before do
|
352
428
|
Stripe.plan "Primo Plan".to_sym do |plan|
|
@@ -370,28 +446,28 @@ describe 'building plans' do
|
|
370
446
|
after { Stripe::Plans.send(:remove_const, :PRIMO_PLAN) }
|
371
447
|
|
372
448
|
it 'is accessible via upcased constant_name' do
|
373
|
-
Stripe::Plans::PRIMO_PLAN.wont_be_nil
|
449
|
+
_(Stripe::Plans::PRIMO_PLAN).wont_be_nil
|
374
450
|
end
|
375
451
|
|
376
452
|
it 'is accessible via collection' do
|
377
|
-
Stripe::Plans.all.must_include Stripe::Plans::PRIMO_PLAN
|
453
|
+
_(Stripe::Plans.all).must_include Stripe::Plans::PRIMO_PLAN
|
378
454
|
end
|
379
455
|
|
380
456
|
it 'is accessible via hash lookup (symbol/string agnostic)' do
|
381
|
-
Stripe::Plans[:primo_plan].must_equal Stripe::Plans::PRIMO_PLAN
|
382
|
-
Stripe::Plans['primo_plan'].must_equal Stripe::Plans::PRIMO_PLAN
|
457
|
+
_(Stripe::Plans[:primo_plan]).must_equal Stripe::Plans::PRIMO_PLAN
|
458
|
+
_(Stripe::Plans['primo_plan']).must_equal Stripe::Plans::PRIMO_PLAN
|
383
459
|
end
|
384
460
|
|
385
461
|
describe 'constant name validation' do
|
386
462
|
it 'should be invalid when providing a constant name that can not be used for Ruby constant' do
|
387
|
-
lambda {
|
463
|
+
_(lambda {
|
388
464
|
Stripe.plan "Primo Plan".to_sym do |plan|
|
389
465
|
plan.name = 'Acme as a service PRIMO'
|
390
466
|
plan.constant_name = 'PRIMO PLAN'
|
391
467
|
plan.amount = 999
|
392
468
|
plan.interval = 'month'
|
393
469
|
end
|
394
|
-
}.must_raise Stripe::InvalidConfigurationError
|
470
|
+
}).must_raise Stripe::InvalidConfigurationError
|
395
471
|
end
|
396
472
|
end
|
397
473
|
|