mustwin-stripe-ruby-mock 1.8.4.10

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 (89) hide show
  1. data/.gitignore +5 -0
  2. data/.rspec +1 -0
  3. data/.travis.yml +5 -0
  4. data/ChangeLog.rdoc +4 -0
  5. data/Gemfile +7 -0
  6. data/LICENSE.txt +22 -0
  7. data/README.md +264 -0
  8. data/Rakefile +28 -0
  9. data/bin/stripe-mock-server +19 -0
  10. data/lib/stripe_mock.rb +46 -0
  11. data/lib/stripe_mock/api/card_tokens.rb +22 -0
  12. data/lib/stripe_mock/api/client.rb +37 -0
  13. data/lib/stripe_mock/api/debug.rb +11 -0
  14. data/lib/stripe_mock/api/errors.rb +41 -0
  15. data/lib/stripe_mock/api/instance.rb +27 -0
  16. data/lib/stripe_mock/api/server.rb +24 -0
  17. data/lib/stripe_mock/api/strict.rb +11 -0
  18. data/lib/stripe_mock/api/webhooks.rb +64 -0
  19. data/lib/stripe_mock/client.rb +84 -0
  20. data/lib/stripe_mock/data.rb +317 -0
  21. data/lib/stripe_mock/error_queue.rb +23 -0
  22. data/lib/stripe_mock/errors/closed_client_connection_error.rb +9 -0
  23. data/lib/stripe_mock/errors/server_timeout_error.rb +12 -0
  24. data/lib/stripe_mock/errors/stripe_mock_error.rb +15 -0
  25. data/lib/stripe_mock/errors/uninitialized_instance_error.rb +9 -0
  26. data/lib/stripe_mock/errors/unstarted_state_error.rb +9 -0
  27. data/lib/stripe_mock/errors/unsupported_request_error.rb +4 -0
  28. data/lib/stripe_mock/instance.rb +108 -0
  29. data/lib/stripe_mock/request_handlers/charges.rb +33 -0
  30. data/lib/stripe_mock/request_handlers/customers.rb +107 -0
  31. data/lib/stripe_mock/request_handlers/invoice_items.rb +15 -0
  32. data/lib/stripe_mock/request_handlers/plans.rb +43 -0
  33. data/lib/stripe_mock/server.rb +58 -0
  34. data/lib/stripe_mock/util.rb +22 -0
  35. data/lib/stripe_mock/version.rb +4 -0
  36. data/lib/stripe_mock/webhook_fixtures/account.application.deauthorized.json +12 -0
  37. data/lib/stripe_mock/webhook_fixtures/account.updated.json +24 -0
  38. data/lib/stripe_mock/webhook_fixtures/charge.dispute.closed.json +21 -0
  39. data/lib/stripe_mock/webhook_fixtures/charge.dispute.created.json +21 -0
  40. data/lib/stripe_mock/webhook_fixtures/charge.dispute.updated.json +24 -0
  41. data/lib/stripe_mock/webhook_fixtures/charge.failed.json +57 -0
  42. data/lib/stripe_mock/webhook_fixtures/charge.refunded.json +57 -0
  43. data/lib/stripe_mock/webhook_fixtures/charge.succeeded.json +57 -0
  44. data/lib/stripe_mock/webhook_fixtures/coupon.created.json +22 -0
  45. data/lib/stripe_mock/webhook_fixtures/coupon.deleted.json +22 -0
  46. data/lib/stripe_mock/webhook_fixtures/customer.created.json +40 -0
  47. data/lib/stripe_mock/webhook_fixtures/customer.deleted.json +40 -0
  48. data/lib/stripe_mock/webhook_fixtures/customer.discount.created.json +28 -0
  49. data/lib/stripe_mock/webhook_fixtures/customer.discount.deleted.json +28 -0
  50. data/lib/stripe_mock/webhook_fixtures/customer.discount.updated.json +43 -0
  51. data/lib/stripe_mock/webhook_fixtures/customer.subscription.created.json +34 -0
  52. data/lib/stripe_mock/webhook_fixtures/customer.subscription.deleted.json +34 -0
  53. data/lib/stripe_mock/webhook_fixtures/customer.subscription.trial_will_end.json +34 -0
  54. data/lib/stripe_mock/webhook_fixtures/customer.subscription.updated.json +47 -0
  55. data/lib/stripe_mock/webhook_fixtures/customer.updated.json +43 -0
  56. data/lib/stripe_mock/webhook_fixtures/invoice.created.json +64 -0
  57. data/lib/stripe_mock/webhook_fixtures/invoice.payment_failed.json +64 -0
  58. data/lib/stripe_mock/webhook_fixtures/invoice.payment_succeeded.json +64 -0
  59. data/lib/stripe_mock/webhook_fixtures/invoice.updated.json +67 -0
  60. data/lib/stripe_mock/webhook_fixtures/invoiceitem.created.json +21 -0
  61. data/lib/stripe_mock/webhook_fixtures/invoiceitem.deleted.json +21 -0
  62. data/lib/stripe_mock/webhook_fixtures/invoiceitem.updated.json +24 -0
  63. data/lib/stripe_mock/webhook_fixtures/plan.created.json +20 -0
  64. data/lib/stripe_mock/webhook_fixtures/plan.deleted.json +20 -0
  65. data/lib/stripe_mock/webhook_fixtures/plan.updated.json +23 -0
  66. data/lib/stripe_mock/webhook_fixtures/transfer.created.json +23 -0
  67. data/lib/stripe_mock/webhook_fixtures/transfer.failed.json +23 -0
  68. data/lib/stripe_mock/webhook_fixtures/transfer.paid.json +23 -0
  69. data/lib/stripe_mock/webhook_fixtures/transfer.updated.json +26 -0
  70. data/lib/trollop.rb +782 -0
  71. data/spec/_dummy/webhooks/dummy.event.json +6 -0
  72. data/spec/fixtures/stripe_webhooks/account.updated.json +7 -0
  73. data/spec/fixtures/stripe_webhooks/custom.account.updated.json +5 -0
  74. data/spec/instance_spec.rb +49 -0
  75. data/spec/readme_spec.rb +72 -0
  76. data/spec/server_spec.rb +131 -0
  77. data/spec/shared_stripe_examples/card_token_examples.rb +28 -0
  78. data/spec/shared_stripe_examples/charge_examples.rb +123 -0
  79. data/spec/shared_stripe_examples/customer_examples.rb +218 -0
  80. data/spec/shared_stripe_examples/error_mock_examples.rb +152 -0
  81. data/spec/shared_stripe_examples/invoice_item_examples.rb +17 -0
  82. data/spec/shared_stripe_examples/plan_examples.rb +123 -0
  83. data/spec/spec_helper.rb +11 -0
  84. data/spec/stripe_mock_spec.rb +40 -0
  85. data/spec/support/stripe_examples.rb +18 -0
  86. data/spec/util_spec.rb +45 -0
  87. data/spec/webhook_spec.rb +77 -0
  88. data/stripe-ruby-mock.gemspec +27 -0
  89. metadata +253 -0
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ html/
2
+ pkg/
3
+ .DS_Store
4
+ stripe-mock-server.pid
5
+ Gemfile.lock
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour --format documentation
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ script: "bundle exec rake"
data/ChangeLog.rdoc ADDED
@@ -0,0 +1,4 @@
1
+ === 0.1.0 / 2013-04-28
2
+
3
+ * Initial release:
4
+
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ group :test do
4
+ gem 'rake'
5
+ end
6
+
7
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2013 Gilbert
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,264 @@
1
+ # stripe-ruby-mock [![Build Status](https://travis-ci.org/rebelidealist/stripe-ruby-mock.png?branch=master)](https://travis-ci.org/rebelidealist/stripe-ruby-mock)
2
+
3
+ * Homepage: https://github.com/rebelidealist/stripe-ruby-mock
4
+ * Issues: https://github.com/rebelidealist/stripe-ruby-mock/issues
5
+
6
+ ## Install
7
+
8
+ In your gemfile:
9
+
10
+ gem 'stripe-ruby-mock', '>= 1.8.4.9'
11
+
12
+ ## Features
13
+
14
+ * No stripe server access required
15
+ * Easily test against stripe errors
16
+ * Mock and customize stripe webhooks
17
+
18
+ ## Description
19
+
20
+ ** *WARNING: This library does not cover all Stripe API endpoints. If you need one that's missing, please create an issue for it.* **
21
+
22
+ At its core, this library overrides [stripe-ruby's](https://github.com/stripe/stripe-ruby)
23
+ request method to skip all http calls and
24
+ instead directly return test data. This allows you to write and run tests
25
+ without the need to actually hit stripe's servers.
26
+
27
+ You can use stripe-ruby-mock with any ruby testing library. Here's a quick dummy example with RSpec:
28
+
29
+ ```ruby
30
+ require 'stripe_mock'
31
+
32
+ describe MyApp do
33
+ before { StripeMock.start }
34
+ after { StripeMock.stop }
35
+
36
+ it "creates a stripe customer" do
37
+
38
+ # This doesn't touch stripe's servers nor the internet!
39
+ customer = Stripe::Customer.create({
40
+ email: 'johnny@appleseed.com',
41
+ card: 'void_card_token'
42
+ })
43
+ expect(customer.email).to eq('johnny@appleseed.com')
44
+ end
45
+ end
46
+ ```
47
+
48
+ ## Mocking Card Errors
49
+
50
+ Tired of manually inputting fake credit card numbers to test against errors? Tire no more!
51
+
52
+ ```ruby
53
+ it "mocks a declined card error" do
54
+ # Prepares an error for the next create charge request
55
+ StripeMock.prepare_card_error(:card_declined)
56
+
57
+ expect { Stripe::Charge.create }.to raise_error {|e|
58
+ expect(e).to be_a Stripe::CardError
59
+ expect(e.http_status).to eq(402)
60
+ expect(e.code).to eq('card_declined')
61
+ }
62
+ end
63
+ ```
64
+
65
+ ### Built-In Card Errors
66
+
67
+ ```ruby
68
+ StripeMock.prepare_card_error(:incorrect_number)
69
+ StripeMock.prepare_card_error(:invalid_number)
70
+ StripeMock.prepare_card_error(:invalid_expiry_month)
71
+ StripeMock.prepare_card_error(:invalid_expiry_year)
72
+ StripeMock.prepare_card_error(:invalid_cvc)
73
+ StripeMock.prepare_card_error(:expired_card)
74
+ StripeMock.prepare_card_error(:incorrect_cvc)
75
+ StripeMock.prepare_card_error(:card_declined)
76
+ StripeMock.prepare_card_error(:missing)
77
+ StripeMock.prepare_card_error(:processing_error)
78
+ ```
79
+
80
+ You can see the details of each error in [lib/stripe_mock/api/errors.rb](lib/stripe_mock/api/errors.rb)
81
+
82
+ ### Custom Errors
83
+
84
+ To raise an error on a specific type of request, take a look at the [request handlers folder](lib/stripe_mock/request_handlers/) and pass a method name to `StripeMock.prepare_error`.
85
+
86
+ If you wanted to raise an error for creating a new customer, for instance, you would do the following:
87
+
88
+ ```ruby
89
+ it "raises a custom error for specific actions" do
90
+ custom_error = StandardError.new("Please knock first.")
91
+
92
+ StripeMock.prepare_error(custom_error, :new_customer)
93
+
94
+ expect { Stripe::Charge.create }.to_not raise_error
95
+ expect { Stripe::Customer.create }.to raise_error {|e|
96
+ expect(e).to be_a StandardError
97
+ expect(e.message).to eq("Please knock first.")
98
+ }
99
+ end
100
+ ```
101
+
102
+ In the above example, `:new_customer` is the name of a method from [customers.rb](lib/stripe_mock/request_handlers/customers.rb).
103
+
104
+ ## Running the Mock Server
105
+
106
+ Sometimes you want your test stripe data to persist for a bit, such as during integration tests
107
+ running on different processes. In such cases you'll want to start the stripe mock server:
108
+
109
+ # spec_helper.rb
110
+ #
111
+ # The mock server will automatically be killed when your tests are done running.
112
+ #
113
+ require 'thin'
114
+ StripeMock.spawn_server
115
+
116
+ Then, instead of `StripeMock.start`, you'll want to use `StripeMock.start_client`:
117
+
118
+ ```ruby
119
+ describe MyApp do
120
+ before do
121
+ @client = StripeMock.start_client
122
+ end
123
+
124
+ after do
125
+ StripeMock.stop_client
126
+ # Alternatively:
127
+ # @client.close!
128
+ # -- Or --
129
+ # StripeMock.stop_client(:clear_server_data => true)
130
+ end
131
+ end
132
+ ```
133
+
134
+ This is all essentially the same as using `StripeMock.start`, except that the stripe test
135
+ data is held in its own server process.
136
+
137
+ Here are some other neat things you can do with the client:
138
+
139
+ ```ruby
140
+ @client.state #=> 'ready'
141
+
142
+ @client.get_server_data(:customers) # Also works for :charges, :plans, etc.
143
+ @client.clear_server_data
144
+
145
+ @client.close!
146
+ @client.state #=> 'closed'
147
+ ```
148
+
149
+ ### Mock Server Options
150
+
151
+ ```ruby
152
+ # NOTE: Shown below are the default options
153
+ StripeMock.default_server_pid_path = './stripe-mock-server.pid'
154
+
155
+ StripeMock.spawn_server(
156
+ :pid_path => StripeMock.default_server_pid_path,
157
+ :host => '0.0.0.0',
158
+ :port => 4999,
159
+ :server => :thin
160
+ )
161
+
162
+ StripeMock.kill_server(StripeMock.default_server_pid_path)
163
+ ```
164
+
165
+ ### Mock Server Command
166
+
167
+ If you need the mock server to continue running even after your tests are done,
168
+ you'll want to use the executable:
169
+
170
+ $ stripe-mock-server -p 4000
171
+ $ stripe-mock-server --help
172
+
173
+ ## Mocking Webhooks
174
+
175
+ If your application handles stripe webhooks, you are most likely retrieving the event from
176
+ stripe and passing the result to a handler. StripeMock helps you by easily mocking that event:
177
+
178
+ ```ruby
179
+ it "mocks a stripe webhook" do
180
+ event = StripeMock.mock_webhook_event('customer.created')
181
+
182
+ customer_object = event.data.object
183
+ expect(customer_object.id).to_not be_nil
184
+ expect(customer_object.active_card).to_not be_nil
185
+ # etc.
186
+ end
187
+ ```
188
+
189
+ ### Customizing Webhooks
190
+
191
+ By default, StripeMock searches in your `spec/fixtures/stripe_webhooks/` folder for your own, custom webhooks.
192
+ If it finds nothing, it falls back to [test events generated through stripe's webhooktester](lib/stripe_mock/webhook_fixtures/).
193
+
194
+ You can name events whatever you like in your `spec/fixtures/stripe_webhooks/` folder. However, if you try to call a non-existant event that's not in that folder, StripeMock will throw an error.
195
+
196
+ If you wish to use a different fixture path, you can set it yourself:
197
+
198
+ StripeMock.webhook_fixture_path = './spec/other/folder/'
199
+
200
+ Also, you can override values whenever you create any webhook event:
201
+
202
+ ```ruby
203
+ it "can override default webhook values" do
204
+ # NOTE: given hash values get merged directly into event.data.object
205
+ event = StripeMock.mock_webhook_event('customer.created', {
206
+ :id => 'cus_my_custom_value',
207
+ :email => 'joe@example.com'
208
+ })
209
+ # Alternatively:
210
+ # event.data.object.id = 'cus_my_custom_value'
211
+ # event.data.object.email = 'joe@example.com'
212
+ expect(event.data.object.id).to eq('cus_my_custom_value')
213
+ expect(event.data.object.email).to eq('joe@example.com')
214
+ end
215
+ ```
216
+
217
+ ## Generating Card Tokens
218
+
219
+ Sometimes you need to check if your code reads a stripe card correctly. If so, you can specifically
220
+ assign card data to a generated card token:
221
+
222
+ ```ruby
223
+ it "generates a stripe card token" do
224
+ card_token = StripeMock.generate_card_token(last4: "9191", exp_year: 1984)
225
+
226
+ cus = Stripe::Customer.create(card: card_token)
227
+ card = cus.cards.data.first
228
+ expect(card.last4).to eq("9191")
229
+ expect(card.exp_year).to eq(1984)
230
+ end
231
+ ```
232
+
233
+ ## Debugging
234
+
235
+ To enable debug messages:
236
+
237
+ StripeMock.toggle_debug(true)
238
+
239
+ This will **only last for the session**; Once you call `StripeMock.stop` or `StripeMock.stop_client`,
240
+ debug will be toggled off.
241
+
242
+ If you always want debug to be on (it's quite verbose), you should put this in a `before` block.
243
+
244
+ ## TODO
245
+
246
+ * Cover all stripe urls/methods
247
+ * Throw useful errors that emulate Stripe's requirements
248
+ * For example: "You must supply either a card or a customer id" for `Stripe::Charge`
249
+
250
+ ## Developing stripe-ruby-mock
251
+
252
+ To run the tests:
253
+
254
+ $ rspec
255
+
256
+ Patches are welcome and greatly appreciated! If you're contributing to fix a problem,
257
+ be sure to write tests that illustrate the problem being fixed.
258
+ This will help ensure that the problem remains fixed in future updates.
259
+
260
+ ## Copyright
261
+
262
+ Copyright (c) 2013 Gilbert
263
+
264
+ See LICENSE.txt for details.
data/Rakefile ADDED
@@ -0,0 +1,28 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'rake'
5
+
6
+ begin
7
+ gem 'rubygems-tasks', '~> 0.2'
8
+ require 'rubygems/tasks'
9
+
10
+ Gem::Tasks.new
11
+ rescue LoadError => e
12
+ warn e.message
13
+ warn "Run `gem install rubygems-tasks` to install Gem::Tasks."
14
+ end
15
+
16
+ begin
17
+ gem 'rspec', '~> 2.4'
18
+ require 'rspec/core/rake_task'
19
+
20
+ RSpec::Core::RakeTask.new
21
+ rescue LoadError => e
22
+ task :spec do
23
+ abort "Please run `gem install rspec` to install RSpec."
24
+ end
25
+ end
26
+
27
+ task :test => :spec
28
+ task :default => :spec
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ lib = File.expand_path(File.dirname(__FILE__) + '/../lib')
4
+ $LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib)
5
+
6
+ require 'trollop'
7
+
8
+ opts = Trollop::options do
9
+ opt :port, "Listening port", :type => :int, :default => 4999
10
+ opt :host, "Host to listen on", :type => :string, :default => '0.0.0.0'
11
+ opt :server, "Server to use", :type => :string, :default => 'thin'
12
+ opt :debug, "Request and response output", :default => true
13
+ opt :pid_path, "Location to put server pid file", :type => :string, :default => './stripe-mock-server.pid'
14
+ end
15
+
16
+ require 'stripe_mock'
17
+ require 'stripe_mock/server'
18
+
19
+ StripeMock::Server.start_new(opts)
@@ -0,0 +1,46 @@
1
+ require 'ostruct'
2
+ require 'jimson-temp'
3
+ require 'dante'
4
+
5
+ require 'stripe'
6
+
7
+ require 'stripe_mock/version'
8
+ require 'stripe_mock/data'
9
+ require 'stripe_mock/util'
10
+ require 'stripe_mock/error_queue'
11
+
12
+ require 'stripe_mock/errors/stripe_mock_error'
13
+ require 'stripe_mock/errors/unsupported_request_error'
14
+ require 'stripe_mock/errors/uninitialized_instance_error'
15
+ require 'stripe_mock/errors/unstarted_state_error'
16
+ require 'stripe_mock/errors/server_timeout_error'
17
+ require 'stripe_mock/errors/closed_client_connection_error'
18
+
19
+ require 'stripe_mock/client'
20
+ require 'stripe_mock/server'
21
+
22
+ require 'stripe_mock/api/instance'
23
+ require 'stripe_mock/api/client'
24
+ require 'stripe_mock/api/server'
25
+ require 'stripe_mock/api/card_tokens'
26
+ require 'stripe_mock/api/errors'
27
+ require 'stripe_mock/api/webhooks'
28
+ require 'stripe_mock/api/strict'
29
+ require 'stripe_mock/api/debug'
30
+
31
+ require 'stripe_mock/request_handlers/charges.rb'
32
+ require 'stripe_mock/request_handlers/customers.rb'
33
+ require 'stripe_mock/request_handlers/invoice_items.rb'
34
+ require 'stripe_mock/request_handlers/plans.rb'
35
+ require 'stripe_mock/instance'
36
+
37
+ module StripeMock
38
+
39
+ lib_dir = File.expand_path(File.dirname(__FILE__), '../..')
40
+ @webhook_fixture_path = './spec/fixtures/stripe_webhooks/'
41
+ @webhook_fixture_fallback_path = File.join(lib_dir, 'stripe_mock/webhook_fixtures')
42
+
43
+ class << self
44
+ attr_accessor :webhook_fixture_path
45
+ end
46
+ end
@@ -0,0 +1,22 @@
1
+ module StripeMock
2
+
3
+ def self.generate_card_token(card_params)
4
+ if @state == 'local'
5
+ instance.generate_card_token(card_params)
6
+ elsif @state == 'remote'
7
+ client.generate_card_token(card_params)
8
+ else
9
+ raise UnstartedStateError
10
+ end
11
+ end
12
+
13
+ def self.generate_recipient_token(recipient_params)
14
+ if @state == 'local'
15
+ instance.generate_recipient_token(recipient_params)
16
+ elsif @state == 'remote'
17
+ client.generate_recipient_token(recipient_params)
18
+ else
19
+ raise UnstartedStateError
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,37 @@
1
+ module StripeMock
2
+
3
+ def self.client; @client; end
4
+
5
+ def self.start_client(port=4999)
6
+ return @client unless @client.nil?
7
+
8
+ alias_stripe_method :request, StripeMock.method(:redirect_to_mock_server)
9
+ @client = StripeMock::Client.new(port)
10
+ @state = 'remote'
11
+ @client
12
+ end
13
+
14
+ def self.stop_client(opts={})
15
+ return false unless @state == 'remote'
16
+ @state = 'ready'
17
+
18
+ alias_stripe_method :request, @original_request_method
19
+ @client.clear_server_data if opts[:clear_server_data] == true
20
+ @client.cleanup
21
+ @client = nil
22
+ true
23
+ end
24
+
25
+ private
26
+
27
+ def self.redirect_to_mock_server(method, url, api_key, params={}, headers={})
28
+ handler = Instance.handler_for_method_url("#{method} #{url}")
29
+ mock_error = client.error_queue.error_for_handler_name(handler[:name])
30
+ if mock_error
31
+ client.error_queue.dequeue
32
+ raise mock_error
33
+ end
34
+ Stripe::Util.symbolize_names client.mock_request(method, url, api_key, params, headers)
35
+ end
36
+
37
+ end