-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #89 from Everapps/no-mock
stop loading stripe-ruby-mock from the gemspec
- Loading branch information
Showing
7 changed files
with
31 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -360,20 +360,22 @@ See the [complete listing of all stripe events][5], and the [webhook tutorial][6 | |
|
||
## Unit testing | ||
|
||
If you want to test your callbacks, you can use the `Stripe::Testing` module to send mocked Stripe events. | ||
If you want to test your callbacks, you can use the `Stripe::Rails::Testing` module to send mocked Stripe events. | ||
|
||
```ruby | ||
require 'stripe/rails/testing' | ||
test "my callback handles new subscription" do | ||
Stripe::Testing.send_event "customer.subscription.created" | ||
Stripe::Rails::Testing.send_event "customer.subscription.created" | ||
# Assertions | ||
end | ||
``` | ||
|
||
You can also overwrite some event properties: ([More info](https://github.com/rebelidealist/stripe-ruby-mock#customizing-webhooks)) | ||
|
||
```ruby | ||
require 'stripe/rails/testing' | ||
test "my callback handles new subscription" do | ||
Stripe::Testing.send_event "customer.subscription.created", { | ||
Stripe::Rails::Testing.send_event "customer.subscription.created", { | ||
:email => "[email protected]", | ||
:account_balance => 40 | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
begin | ||
require 'stripe_mock' | ||
rescue LoadError | ||
warn %q{Please add "gem 'stripe-ruby-mock', group: 'test'"" to the Gemfile to use Stripe::Rails::Testing"} | ||
exit | ||
end | ||
require 'stripe/callbacks' | ||
|
||
module Stripe | ||
module Rails | ||
module Testing | ||
def self.send_event(event, properties = {}) | ||
evt = StripeMock.mock_webhook_event(event, properties) | ||
target = evt.data.object | ||
::Stripe::Callbacks.run_callbacks(evt, target) | ||
end | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters