stripe-ruby-mock 1.10.1.7 → 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.
Files changed (71) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +1 -0
  3. data/README.md +70 -3
  4. data/Rakefile +1 -1
  5. data/lib/stripe_mock/api/client.rb +1 -0
  6. data/lib/stripe_mock/api/instance.rb +1 -0
  7. data/lib/stripe_mock/api/live.rb +15 -0
  8. data/lib/stripe_mock/api/server.rb +24 -21
  9. data/lib/stripe_mock/api/test_helpers.rb +24 -0
  10. data/lib/stripe_mock/client.rb +4 -8
  11. data/lib/stripe_mock/data.rb +54 -30
  12. data/lib/stripe_mock/instance.rb +15 -5
  13. data/lib/stripe_mock/request_handlers/cards.rb +29 -18
  14. data/lib/stripe_mock/request_handlers/charges.rb +34 -6
  15. data/lib/stripe_mock/request_handlers/coupons.rb +1 -3
  16. data/lib/stripe_mock/request_handlers/customers.rb +3 -9
  17. data/lib/stripe_mock/request_handlers/events.rb +1 -3
  18. data/lib/stripe_mock/request_handlers/helpers/card_helpers.rb +16 -9
  19. data/lib/stripe_mock/request_handlers/helpers/charge_helpers.rb +16 -0
  20. data/lib/stripe_mock/request_handlers/helpers/subscription_helpers.rb +9 -2
  21. data/lib/stripe_mock/request_handlers/helpers/token_helpers.rb +3 -1
  22. data/lib/stripe_mock/request_handlers/invoice_items.rb +32 -2
  23. data/lib/stripe_mock/request_handlers/invoices.rb +7 -3
  24. data/lib/stripe_mock/request_handlers/plans.rb +2 -5
  25. data/lib/stripe_mock/request_handlers/recipients.rb +26 -4
  26. data/lib/stripe_mock/request_handlers/subscriptions.rb +26 -33
  27. data/lib/stripe_mock/request_handlers/tokens.rb +24 -4
  28. data/lib/stripe_mock/request_handlers/validators/param_validators.rb +18 -0
  29. data/lib/stripe_mock/server.rb +4 -5
  30. data/lib/stripe_mock/test_strategies/base.rb +27 -0
  31. data/lib/stripe_mock/test_strategies/live.rb +22 -0
  32. data/lib/stripe_mock/test_strategies/mock.rb +19 -0
  33. data/lib/stripe_mock/util.rb +5 -0
  34. data/lib/stripe_mock/version.rb +1 -1
  35. data/lib/stripe_mock/webhook_fixtures/charge.failed.json +3 -2
  36. data/lib/stripe_mock/webhook_fixtures/charge.refunded.json +16 -9
  37. data/lib/stripe_mock/webhook_fixtures/charge.succeeded.json +3 -2
  38. data/lib/stripe_mock/webhook_fixtures/customer.card.created.json +1 -0
  39. data/lib/stripe_mock/webhook_fixtures/customer.card.deleted.json +1 -0
  40. data/lib/stripe_mock/webhook_fixtures/customer.card.updated.json +1 -0
  41. data/lib/stripe_mock/webhook_fixtures/customer.created.json +1 -0
  42. data/lib/stripe_mock/webhook_fixtures/customer.deleted.json +2 -1
  43. data/lib/stripe_mock/webhook_fixtures/customer.updated.json +1 -0
  44. data/lib/stripe_mock.rb +9 -1
  45. data/spec/fixtures/create_refund.yml +126 -0
  46. data/spec/instance_spec.rb +4 -2
  47. data/spec/integration_examples/charge_token_examples.rb +49 -0
  48. data/spec/integration_examples/customer_card_examples.rb +42 -0
  49. data/spec/integration_examples/prepare_error_examples.rb +18 -0
  50. data/spec/readme_spec.rb +2 -1
  51. data/spec/server_spec.rb +12 -3
  52. data/spec/shared_stripe_examples/card_examples.rb +108 -3
  53. data/spec/shared_stripe_examples/card_token_examples.rb +26 -0
  54. data/spec/shared_stripe_examples/charge_examples.rb +55 -39
  55. data/spec/shared_stripe_examples/coupon_examples.rb +2 -17
  56. data/spec/shared_stripe_examples/customer_examples.rb +30 -39
  57. data/spec/shared_stripe_examples/error_mock_examples.rb +1 -1
  58. data/spec/shared_stripe_examples/invoice_examples.rb +31 -15
  59. data/spec/shared_stripe_examples/invoice_item_examples.rb +62 -10
  60. data/spec/shared_stripe_examples/plan_examples.rb +29 -18
  61. data/spec/shared_stripe_examples/recipient_examples.rb +55 -5
  62. data/spec/shared_stripe_examples/refund_examples.rb +90 -0
  63. data/spec/shared_stripe_examples/subscription_examples.rb +159 -82
  64. data/spec/shared_stripe_examples/validation_examples.rb +19 -0
  65. data/spec/spec_helper.rb +32 -1
  66. data/spec/stripe_mock_spec.rb +70 -0
  67. data/spec/support/stripe_examples.rb +7 -14
  68. data/spec/util_spec.rb +8 -0
  69. data/stripe-ruby-mock.gemspec +2 -2
  70. metadata +38 -34
  71. data/lib/stripe_mock/api/strict.rb +0 -11
@@ -1,19 +1,7 @@
1
1
 
2
2
  def require_stripe_examples
3
- require 'shared_stripe_examples/bank_token_examples'
4
- require 'shared_stripe_examples/card_token_examples'
5
- require 'shared_stripe_examples/card_examples'
6
- require 'shared_stripe_examples/charge_examples'
7
- require 'shared_stripe_examples/coupon_examples'
8
- require 'shared_stripe_examples/customer_examples'
9
- require 'shared_stripe_examples/error_mock_examples'
10
- require 'shared_stripe_examples/extra_features_examples'
11
- require 'shared_stripe_examples/invoice_examples'
12
- require 'shared_stripe_examples/invoice_item_examples'
13
- require 'shared_stripe_examples/plan_examples'
14
- require 'shared_stripe_examples/recipient_examples'
15
- require 'shared_stripe_examples/subscription_examples'
16
- require 'shared_stripe_examples/webhook_event_examples'
3
+ Dir["./spec/shared_stripe_examples/**/*.rb"].each {|f| require f}
4
+ Dir["./spec/integration_examples/**/*.rb"].each {|f| require f}
17
5
  end
18
6
 
19
7
  def it_behaves_like_stripe(&block)
@@ -28,7 +16,12 @@ def it_behaves_like_stripe(&block)
28
16
  it_behaves_like 'Invoice Item API', &block
29
17
  it_behaves_like 'Plan API', &block
30
18
  it_behaves_like 'Recipient API', &block
19
+ it_behaves_like 'Refund API', &block
31
20
  it_behaves_like 'Stripe Error Mocking', &block
32
21
  it_behaves_like 'Customer Subscriptions', &block
33
22
  it_behaves_like 'Webhook Events API', &block
23
+
24
+ # Integration tests
25
+ it_behaves_like 'Multiple Customer Cards'
26
+ it_behaves_like 'Charging with Tokens'
34
27
  end
data/spec/util_spec.rb CHANGED
@@ -26,6 +26,14 @@ describe StripeMock::Util do
26
26
  expect(result).to eq({ x: [ {a: 0}, {a: 0, b: 2}, {c: 3} ] })
27
27
  end
28
28
 
29
+ it "does not truncate the array when merging" do
30
+ dest = { x: [ {a: 1}, {b: 2} ] }
31
+ source = { x: [ nil, nil, {c: 3} ] }
32
+ result = StripeMock::Util.rmerge(dest, source)
33
+
34
+ expect(result).to eq({ x: [ {a: 1}, {b: 2}, {c: 3} ] })
35
+ end
36
+
29
37
  it "treats an array nil element as a skip op" do
30
38
  dest = { x: [ {a: 1}, {b: 2}, {c: 3} ] }
31
39
  source = { x: [ nil, nil, {c: 0} ] }
@@ -17,11 +17,11 @@ Gem::Specification.new do |gem|
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ['lib']
19
19
 
20
- gem.add_dependency 'stripe', '>= 1.10.1'
20
+ gem.add_dependency 'stripe', '>= 1.15.0'
21
21
  gem.add_dependency 'jimson-temp'
22
22
  gem.add_dependency 'dante', '>= 0.2.0'
23
23
 
24
- gem.add_development_dependency 'rspec', '~> 2.4'
24
+ gem.add_development_dependency 'rspec', '~> 3.1.0'
25
25
  gem.add_development_dependency 'rubygems-tasks', '~> 0.2'
26
26
  gem.add_development_dependency 'thin'
27
27
  end
metadata CHANGED
@@ -1,84 +1,74 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stripe-ruby-mock
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.1.7
5
- prerelease:
4
+ version: 2.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Gilbert
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-04-20 00:00:00.000000000 Z
11
+ date: 2014-10-27 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: stripe
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
- version: 1.10.1
19
+ version: 1.15.0
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
- version: 1.10.1
26
+ version: 1.15.0
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: jimson-temp
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: dante
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: 0.2.0
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: 0.2.0
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rspec
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - ~>
68
60
  - !ruby/object:Gem::Version
69
- version: '2.4'
61
+ version: 3.1.0
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - ~>
76
67
  - !ruby/object:Gem::Version
77
- version: '2.4'
68
+ version: 3.1.0
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: rubygems-tasks
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
73
  - - ~>
84
74
  - !ruby/object:Gem::Version
@@ -86,7 +76,6 @@ dependencies:
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
80
  - - ~>
92
81
  - !ruby/object:Gem::Version
@@ -94,17 +83,15 @@ dependencies:
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: thin
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
- - - ! '>='
87
+ - - '>='
100
88
  - !ruby/object:Gem::Version
101
89
  version: '0'
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
- - - ! '>='
94
+ - - '>='
108
95
  - !ruby/object:Gem::Version
109
96
  version: '0'
110
97
  description: A drop-in library to test stripe without hitting their servers
@@ -131,8 +118,9 @@ files:
131
118
  - lib/stripe_mock/api/errors.rb
132
119
  - lib/stripe_mock/api/global_id_prefix.rb
133
120
  - lib/stripe_mock/api/instance.rb
121
+ - lib/stripe_mock/api/live.rb
134
122
  - lib/stripe_mock/api/server.rb
135
- - lib/stripe_mock/api/strict.rb
123
+ - lib/stripe_mock/api/test_helpers.rb
136
124
  - lib/stripe_mock/api/webhooks.rb
137
125
  - lib/stripe_mock/client.rb
138
126
  - lib/stripe_mock/data.rb
@@ -150,6 +138,7 @@ files:
150
138
  - lib/stripe_mock/request_handlers/customers.rb
151
139
  - lib/stripe_mock/request_handlers/events.rb
152
140
  - lib/stripe_mock/request_handlers/helpers/card_helpers.rb
141
+ - lib/stripe_mock/request_handlers/helpers/charge_helpers.rb
153
142
  - lib/stripe_mock/request_handlers/helpers/subscription_helpers.rb
154
143
  - lib/stripe_mock/request_handlers/helpers/token_helpers.rb
155
144
  - lib/stripe_mock/request_handlers/invoice_items.rb
@@ -158,7 +147,11 @@ files:
158
147
  - lib/stripe_mock/request_handlers/recipients.rb
159
148
  - lib/stripe_mock/request_handlers/subscriptions.rb
160
149
  - lib/stripe_mock/request_handlers/tokens.rb
150
+ - lib/stripe_mock/request_handlers/validators/param_validators.rb
161
151
  - lib/stripe_mock/server.rb
152
+ - lib/stripe_mock/test_strategies/base.rb
153
+ - lib/stripe_mock/test_strategies/live.rb
154
+ - lib/stripe_mock/test_strategies/mock.rb
162
155
  - lib/stripe_mock/util.rb
163
156
  - lib/stripe_mock/version.rb
164
157
  - lib/stripe_mock/webhook_fixtures/account.application.deauthorized.json
@@ -201,9 +194,13 @@ files:
201
194
  - lib/stripe_mock/webhook_fixtures/transfer.updated.json
202
195
  - lib/trollop.rb
203
196
  - spec/_dummy/webhooks/dummy.event.json
197
+ - spec/fixtures/create_refund.yml
204
198
  - spec/fixtures/stripe_webhooks/account.updated.json
205
199
  - spec/fixtures/stripe_webhooks/custom.account.updated.json
206
200
  - spec/instance_spec.rb
201
+ - spec/integration_examples/charge_token_examples.rb
202
+ - spec/integration_examples/customer_card_examples.rb
203
+ - spec/integration_examples/prepare_error_examples.rb
207
204
  - spec/readme_spec.rb
208
205
  - spec/server_spec.rb
209
206
  - spec/shared_stripe_examples/bank_token_examples.rb
@@ -218,7 +215,9 @@ files:
218
215
  - spec/shared_stripe_examples/invoice_item_examples.rb
219
216
  - spec/shared_stripe_examples/plan_examples.rb
220
217
  - spec/shared_stripe_examples/recipient_examples.rb
218
+ - spec/shared_stripe_examples/refund_examples.rb
221
219
  - spec/shared_stripe_examples/subscription_examples.rb
220
+ - spec/shared_stripe_examples/validation_examples.rb
222
221
  - spec/shared_stripe_examples/webhook_event_examples.rb
223
222
  - spec/spec_helper.rb
224
223
  - spec/stripe_mock_spec.rb
@@ -228,33 +227,36 @@ files:
228
227
  homepage: https://github.com/rebelidealist/stripe-ruby-mock
229
228
  licenses:
230
229
  - MIT
230
+ metadata: {}
231
231
  post_install_message:
232
232
  rdoc_options: []
233
233
  require_paths:
234
234
  - lib
235
235
  required_ruby_version: !ruby/object:Gem::Requirement
236
- none: false
237
236
  requirements:
238
- - - ! '>='
237
+ - - '>='
239
238
  - !ruby/object:Gem::Version
240
239
  version: '0'
241
240
  required_rubygems_version: !ruby/object:Gem::Requirement
242
- none: false
243
241
  requirements:
244
- - - ! '>='
242
+ - - '>='
245
243
  - !ruby/object:Gem::Version
246
244
  version: '0'
247
245
  requirements: []
248
246
  rubyforge_project:
249
- rubygems_version: 1.8.25
247
+ rubygems_version: 2.2.2
250
248
  signing_key:
251
- specification_version: 3
249
+ specification_version: 4
252
250
  summary: TDD with stripe
253
251
  test_files:
254
252
  - spec/_dummy/webhooks/dummy.event.json
253
+ - spec/fixtures/create_refund.yml
255
254
  - spec/fixtures/stripe_webhooks/account.updated.json
256
255
  - spec/fixtures/stripe_webhooks/custom.account.updated.json
257
256
  - spec/instance_spec.rb
257
+ - spec/integration_examples/charge_token_examples.rb
258
+ - spec/integration_examples/customer_card_examples.rb
259
+ - spec/integration_examples/prepare_error_examples.rb
258
260
  - spec/readme_spec.rb
259
261
  - spec/server_spec.rb
260
262
  - spec/shared_stripe_examples/bank_token_examples.rb
@@ -269,7 +271,9 @@ test_files:
269
271
  - spec/shared_stripe_examples/invoice_item_examples.rb
270
272
  - spec/shared_stripe_examples/plan_examples.rb
271
273
  - spec/shared_stripe_examples/recipient_examples.rb
274
+ - spec/shared_stripe_examples/refund_examples.rb
272
275
  - spec/shared_stripe_examples/subscription_examples.rb
276
+ - spec/shared_stripe_examples/validation_examples.rb
273
277
  - spec/shared_stripe_examples/webhook_event_examples.rb
274
278
  - spec/spec_helper.rb
275
279
  - spec/stripe_mock_spec.rb
@@ -1,11 +0,0 @@
1
- module StripeMock
2
-
3
- def self.toggle_strict(toggle)
4
- if @state == 'local'
5
- @instance.strict = toggle
6
- elsif @state == 'remote'
7
- @client.set_server_strict(toggle)
8
- end
9
- end
10
-
11
- end