Sha256: d5a0924cc3c7cae815637d1f92eace127a0f87f66229ace63146d0b5fe256415

Contents?: true

Size: 1.07 KB

Versions: 15

Compression:

Stored size: 1.07 KB

Contents

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({ :id => 1, :foo => 'bar' })
      assert obj.respond_to?(:id)
      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' }, {:api_key => 'apikey'})
      m = Marshal.load(Marshal.dump(obj))
      assert_equal 1, m.id
      assert_equal 'Stripe', m.name
      expected_hash = {:api_key => 'apikey'}
      assert_equal expected_hash, m.instance_variable_get('@opts')
    end

    should "recursively call to_hash on its values" do
      nested = Stripe::StripeObject.construct_from({ :id => 7, :foo => 'bar' })
      obj = Stripe::StripeObject.construct_from({ :id => 1, :nested => nested })
      expected_hash = { :id => 1, :nested => { :id => 7, :foo => 'bar' } }
      assert_equal expected_hash, obj.to_hash
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
stripe-1.27.2 test/stripe/stripe_object_test.rb
stripe-1.27.1 test/stripe/stripe_object_test.rb
stripe-1.27.0 test/stripe/stripe_object_test.rb
stripe-1.26.0 test/stripe/stripe_object_test.rb
stripe-1.25.0 test/stripe/stripe_object_test.rb
stripe-1.24.0 test/stripe/stripe_object_test.rb
stripe-1.23.0 test/stripe/stripe_object_test.rb
stripe-1.22.0 test/stripe/stripe_object_test.rb
stripe-1.21.0 test/stripe/stripe_object_test.rb
stripe-1.20.4 test/stripe/stripe_object_test.rb
stripe-1.20.3 test/stripe/stripe_object_test.rb
stripe-1.20.2 test/stripe/stripe_object_test.rb
stripe-1.20.1 test/stripe/stripe_object_test.rb
stripe-1.20.0 test/stripe/stripe_object_test.rb
stripe-1.19.0 test/stripe/stripe_object_test.rb