stripe-ruby/test/stripe/webhook_endpoint_test.rb
Olivier Bellone ec91de6849
Upgrade Rubocop and fix a bunch of issues (#786)
* Bump Rubocop to 0.57.2

* Style/StderrPuts: Use warn instead of .puts

* Style/ExpandPathArguments: Use expand_path('../test_helper', __dir__) instead of expand_path('../../test_helper', __FILE__)

* Style/Encoding: Unnecessary utf-8 encoding comment

* Style/StringLiterals: Prefer double-quoted strings

* Style/AccessModifierDeclarations

* Style/FormatStringToken: Prefer annotated tokens

* Naming/UncommunicativeMethodParamName

* Metrics/LineLength: set maximum line length to 100 characters

* Style/IfUnlessModifier: Favor modifier if usage when having a single-line body

* Style/ClassVars

* Metrics/LineLength: set maximum line length to 80 characters (default)

* Style/AccessModifierDeclarations: EnforcedStyle: inline
2019-05-24 10:43:42 -07:00

60 lines
2.2 KiB
Ruby

# frozen_string_literal: true
require ::File.expand_path("../test_helper", __dir__)
module Stripe
class WebhookEndpointTest < Test::Unit::TestCase
should "be listable" do
webhook_endpoints = Stripe::WebhookEndpoint.list
assert_requested :get, "#{Stripe.api_base}/v1/webhook_endpoints"
assert webhook_endpoints.data.is_a?(Array)
assert webhook_endpoints.first.is_a?(Stripe::WebhookEndpoint)
end
should "be retrievable" do
webhook_endpoint = Stripe::WebhookEndpoint.retrieve("we_123")
assert_requested :get, "#{Stripe.api_base}/v1/webhook_endpoints/we_123"
assert webhook_endpoint.is_a?(Stripe::WebhookEndpoint)
end
should "be creatable" do
webhook_endpoint = Stripe::WebhookEndpoint.create(
enabled_events: ["charge.succeeded"],
url: "https://stripe.com"
)
assert_requested :post, "#{Stripe.api_base}/v1/webhook_endpoints"
assert webhook_endpoint.is_a?(Stripe::WebhookEndpoint)
end
should "be saveable" do
webhook_endpoint = Stripe::WebhookEndpoint.retrieve("we_123")
webhook_endpoint.enabled_events = ["charge.succeeded"]
webhook_endpoint.save
assert_requested :post, "#{Stripe.api_base}/v1/webhook_endpoints/#{webhook_endpoint.id}"
end
should "be updateable" do
webhook_endpoint = Stripe::WebhookEndpoint.update("we_123", enabled_events: ["charge.succeeded"])
assert_requested :post, "#{Stripe.api_base}/v1/webhook_endpoints/we_123"
assert webhook_endpoint.is_a?(Stripe::WebhookEndpoint)
end
context "#delete" do
should "be deletable" do
webhook_endpoint = Stripe::WebhookEndpoint.retrieve("we_123")
webhook_endpoint = webhook_endpoint.delete
assert_requested :delete, "#{Stripe.api_base}/v1/webhook_endpoints/#{webhook_endpoint.id}"
assert webhook_endpoint.is_a?(Stripe::WebhookEndpoint)
end
end
context ".delete" do
should "be deletable" do
webhook_endpoint = Stripe::WebhookEndpoint.delete("we_123")
assert_requested :delete, "#{Stripe.api_base}/v1/webhook_endpoints/we_123"
assert webhook_endpoint.is_a?(Stripe::WebhookEndpoint)
end
end
end
end