Sha256: 15bf4c479f1ecd12583c00f8277e8f1fe19e9678f5e0dd230c0971c2965acaf9
Contents?: true
Size: 981 Bytes
Versions: 9
Compression:
Stored size: 981 Bytes
Contents
require File.expand_path('../../test_helper', __FILE__) module Paid class PaidObjectTest < Test::Unit::TestCase should "implement #respond_to correctly" do obj = Paid::PaidObject.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 paid object correctly" do obj = Paid::PaidObject.construct_from({ :id => 1, :name => 'Paid' }, 'apikey') m = Marshal.load(Marshal.dump(obj)) assert_equal 1, m.id assert_equal 'Paid', m.name assert_equal 'apikey', m.api_key end should "recursively call to_hash on its values" do nested = Paid::PaidObject.construct_from({ :id => 7, :foo => 'bar' }) obj = Paid::PaidObject.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
9 entries across 9 versions & 1 rubygems