diff --git a/README.md b/README.md index a62bc7de..d1b44944 100644 --- a/README.md +++ b/README.md @@ -367,7 +367,7 @@ background terminal ([stripe-mock's README][stripe-mock] also contains instructions for installing via Homebrew and other methods): ```sh -go get -u github.com/stripe/stripe-mock +go install github.com/stripe/stripe-mock@latest stripe-mock ``` diff --git a/lib/stripe/api_resource.rb b/lib/stripe/api_resource.rb index 7ac3f3cc..4a4c9ef9 100644 --- a/lib/stripe/api_resource.rb +++ b/lib/stripe/api_resource.rb @@ -110,7 +110,6 @@ def self.retrieve(id, opts = {}) opts = Util.normalize_opts(opts) instance = new(id, opts) instance.refresh - instance end def request_stripe_object(method:, path:, params:, base_address: :api, opts: {}) diff --git a/test/stripe/api_resource_test.rb b/test/stripe/api_resource_test.rb index e6dc9e60..c283aa5a 100644 --- a/test/stripe/api_resource_test.rb +++ b/test/stripe/api_resource_test.rb @@ -919,6 +919,23 @@ def self.object_name end end + class CustomStripeObject < APIResource + def self.resource_url + "/v1/custom_stripe_object" + end + end + + context "custom class extending APIResource" do + should "return StripeObject instance when calling retrieve" do + stub_request(:get, "#{Stripe.api_base}/v1/custom_stripe_object/id") + .to_return(body: JSON.generate({ id: "id", object: "custom_stripe_object", result: "hello" })) + + custom_stripe_object = CustomStripeObject.retrieve("id") + assert_instance_of Stripe::StripeObject, custom_stripe_object + assert_equal "hello", custom_stripe_object.result + end + end + @@fixtures = {} # rubocop:disable Style/ClassVars setup do if @@fixtures.empty?