mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-12-09 00:01:53 -05:00
fixed marshaling of stripe objects, fixes #90
This commit is contained in:
parent
8b3a00c587
commit
e717ee711e
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user