Created
June 4, 2015 18:44
-
-
Save ryansch/ef0a3f74ac5a81b4f949 to your computer and use it in GitHub Desktop.
Chargify Webhook Feature Test
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
require 'feature/feature_helper' | |
feature 'Something involving chargify webhooks', :vcr, driver: :mechanize do | |
def chargify_webhook(from:, to:, subscription_id:) | |
payload = {subscription: { | |
id: subscription_id, | |
previous_state: from, | |
state: to | |
# Any other needed subscription info should go here | |
}} | |
using_session(:chargify) do | |
page.driver.browser.process_and_follow_redirects( | |
:post, | |
chargify_hooks_path, | |
{event: :subscription_state_change, payload: payload}, | |
{'X-Chargify-Webhook-Signature-Hmac-Sha-256' => 'deadbeef'} | |
) | |
end | |
end | |
scenario 'Sign up, dunning, cancellation' do | |
# Test set up, Sign up | |
# Trigger dunning | |
chargify_webhook(from: :active, to: :past_due, subscription_id: 123) | |
# Trigger cancellation | |
chargify_webhook(from: :past_due, to: :canceled, subscription_id: 123) | |
# Expectations, etc | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment