Sha256: e46ad17a68a1101c536cb45af070481bb786864a153ac34e25c0e4f49ae1a34f
Contents?: true
Size: 1.37 KB
Versions: 4
Compression:
Stored size: 1.37 KB
Contents
require File.expand_path('../../test_helper', __FILE__) module Rainforest class UtilTest < ::Test::Unit::TestCase context '#symbolize_keys' do should "convert keys to symbols" do start = { 'foo' => 'bar', 'array' => [{ 'foo' => 'bar' }], 'nested' => { 1 => 2, :symbol => 9, 'string' => nil } } finish = { :foo => 'bar', :array => [{ :foo => 'bar' }], :nested => { 1 => 2, :symbol => 9, :string => nil } } symbolized = Util.symbolize_keys(start) assert_equal(finish, symbolized) end end context '#sorta_deep_clone' do # Super hand wavy test.. but it works for now so whatever. should 'clone well enough that we dont accidentally alter json' do start = { :a => "abc", :b => [ { :c => "c-1" }, { :c => "c-2" } ] } cloned = Util.sorta_deep_clone(start) cloned[:a] = "123" cloned[:b] << { :c => "c-3" } cloned[:b][0][:c] = "c-one" assert_equal({ :a => "abc", :b => [ { :c => "c-1" }, { :c => "c-2" } ] }, start) end end context '#constantize' do should 'convert :ApiResource to the class object' do assert_equal(ApiResource, Util.constantize(:ApiResource)) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
rainforest-2.1.0 | test/rainforest/util_test.rb |
rainforest-2.0.2 | test/rainforest/util_test.rb |
rainforest-2.0.1 | test/rainforest/util_test.rb |
rainforest-2.0.0 | test/rainforest/util_test.rb |