Closed noctivityinc closed 10 years ago
Take a look at this example application: https://github.com/invisiblefunnel/test-hooks. If you find it helpful I'll add it to the README.
The main thing is to stub out the HTTP request which retrieves the event from Stripe. Then you can return the JSON collected from RequestBin as though it was returned directly from Stripe.
So if I am reading this correctly, you are taking advantage of the security check that is already in Stripe Event and basically telling the spec that when it makes the request to api.stripe.com, intercept them and supply the JSON in the fixture, is that correct?
Thanks!
Joshua Lippiner
.:t 704.323.5661
.:e jlippiner@noctivity.com
Is this one of 20 or more emails in your inbox?
You need a doorman for your inbox!! (Which I created :))
Check out Taper by Clicking Here (http://www.kickstarter.com/projects/1369431496/taper-the-end-of-email-overload) Now. Thanks!
On Friday, November 15, 2013 at 3:51 PM, Danny Whalen wrote:
Take a look at this example application: https://github.com/invisiblefunnel/test-hooks. If you find it helpful I'll add it to the README. The main thing is to stub out the HTTP request which retrieves the event from Stripe. Then you can return the JSON collected from RequestBin as though it was returned directly from Stripe.
— Reply to this email directly or view it on GitHub (https://github.com/integrallis/stripe_event/issues/25#issuecomment-28602328).
Exactly. This is how I recommend testing Stripe webhooks. Thanks for your question; I've wanted to build an example app for a while.
Did you just create that app? I spent ALL DAY looking for something like that. Im going to test it right now but THANK YOU.
Joshua Lippiner
.:t 704.323.5661
.:e jlippiner@noctivity.com
Is this one of 20 or more emails in your inbox?
You need a doorman for your inbox!! (Which I created :))
Check out Taper by Clicking Here (http://www.kickstarter.com/projects/1369431496/taper-the-end-of-email-overload) Now. Thanks!
On Friday, November 15, 2013 at 4:35 PM, Danny Whalen wrote:
Exactly. This is how I recommend testing Stripe webhooks. Thanks for your question; I've wanted to build an example app for a while.
— Reply to this email directly or view it on GitHub (https://github.com/integrallis/stripe_event/issues/25#issuecomment-28605373).
You're welcome. If you have any feedback on the example app please let me know and I'll incorporate it when I add a testing section to the StripeEvent readme.
YES!! Ok - I FINALLY got the tests to work. It was fine but here were the gotchas that I found:
require 'webmock/rspec'
in spec_helperhttps://api.stripe.com/v1/events/EVENT_ID
based on what you pass it and when using this example as is you must name the fixture the same as the event id. I might recommend changing the method to something like this as it did cause some confusion for me:
def stub_event(fixture_id, json_file = nil)
json_file ||= fixture_id
stub_request(:get, "https://api.stripe.com/v1/events/#{fixture_id}").
to_return(:status => 200, :body => File.read(File.expand_path("../../fixtures/stripe/#{fixture_id}.json", __FILE__)))
end
but other than that it was GREAT!
Thanks!
I feel like I MUST be missing something. This should be MUCH easier but Ive spent hours on this.
Using the dashboard (not test webhooks as the README states) I created a bunch of actions. I used RequestBin to capture the raw response and saved them locally to fixture files.
I then created a spec to post the data to the server to test the hooks. It simply doesnt work. I either get 500 errors due to Hash Indifference or the events are processed as strings.
Here is are some examples:
which returns an Unauthorized. I've also tried doing different variations of these:
I simply need a way to create specs for every possible hook I have wired up for testing. Ideally I dont need to actually perform every one of those actions on Stripe to get the response.
How can I stub and test the various event types without going crazy?