Created
March 14, 2017 15:51
-
-
Save madwork/8c7a322bf0543812dd5f8fcff511d277 to your computer and use it in GitHub Desktop.
Self executable gist for StripeObject marshalling issue
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
unless File.exist?('Gemfile') | |
File.write('Gemfile', <<-GEMFILE) | |
source 'https://rubygems.org' | |
gem 'stripe', '1.58.0' | |
gem 'minitest' | |
GEMFILE | |
system 'bundle' | |
end | |
require 'bundler' | |
Bundler.setup(:default) | |
require 'minitest/autorun' | |
require 'stripe' | |
Stripe.api_key = ENV['STRIPE_API_KEY'] | |
class StripeTest < Minitest::Test | |
def setup | |
@customer = Stripe::Customer.create email: "[email protected]" | |
end | |
def teardown | |
@customer.delete | |
end | |
def test_marshal_stripe_object | |
m = Marshal.load(Marshal.dump(@customer)) | |
assert_equal @customer.id, m.id | |
end | |
def test_stripe_object_opts | |
assert_equal Hash(:api_key => Stripe.api_key), @customer.instance_variable_get('@opts') | |
end | |
end |
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
unless File.exist?('Gemfile') | |
File.write('Gemfile', <<-GEMFILE) | |
source 'https://rubygems.org' | |
gem 'stripe', '2.0.1' | |
gem 'minitest' | |
GEMFILE | |
system 'bundle' | |
end | |
require 'bundler' | |
Bundler.setup(:default) | |
require 'minitest/autorun' | |
require 'stripe' | |
Stripe.api_key = ENV['STRIPE_API_KEY'] | |
class StripeTest < Minitest::Test | |
def setup | |
@customer = Stripe::Customer.create email: "[email protected]" | |
end | |
def teardown | |
@customer.delete | |
end | |
def test_marshal_stripe_object | |
m = Marshal.load(Marshal.dump(@customer)) | |
assert_equal @customer.id, m.id | |
end | |
def test_stripe_object_opts | |
assert_equal Hash(:api_key => Stripe.api_key), @customer.instance_variable_get('@opts') | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment