fixed marshaling of stripe objects, fixes #90

This commit is contained in:
Andrew Thorp 2014-01-24 22:52:57 -08:00
parent 8b3a00c587
commit e717ee711e
2 changed files with 18 additions and 4 deletions

View File

@ -102,6 +102,14 @@ module Stripe
@values.each(&blk)
end
def marshal_dump
@values
end
def marshal_load(values)
@values = values
end
protected
def metaclass

View File

@ -3,11 +3,17 @@ require File.expand_path('../../test_helper', __FILE__)
module Stripe
class StripeObjectTest < Test::Unit::TestCase
should "implement #respond_to correctly" do
obj = Stripe::StripeObject.construct_from({ :some_key => "something", :id => 123 })
obj = Stripe::StripeObject.construct_from({ id: 1, foo: 'bar' })
assert obj.respond_to?(:id)
assert obj.respond_to?(:some_key)
assert !obj.respond_to?(:some_other_key)
assert obj.respond_to?(:foo)
assert !obj.respond_to?(:baz)
end
should "marshal a stripe object correctly" do
obj = Stripe::StripeObject.construct_from({ id: 1, name: 'Stripe' })
m = Marshal.load(Marshal.dump(obj))
assert_equal m.id, 1
assert_equal m.name, 'Stripe'
end
end
end