Skip to content

Instantly share code, notes, and snippets.

@madwork
Created March 14, 2017 15:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save madwork/8c7a322bf0543812dd5f8fcff511d277 to your computer and use it in GitHub Desktop.
Save madwork/8c7a322bf0543812dd5f8fcff511d277 to your computer and use it in GitHub Desktop.
Self executable gist for StripeObject marshalling issue
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: "foo@github.com"
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
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: "foo@github.com"
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