Sha256: 1e1f6cb20e2ff4113462c83439a78d4dcbb7eed5c7a71594b22ca9b9e1fbafc4
Contents?: true
Size: 865 Bytes
Versions: 15
Compression:
Stored size: 865 Bytes
Contents
require 'native' describe Hash do it 'turns a native JS object into a hash' do obj = %x{ { a: 1, b: "two", c: { d: 1, }, e: [ { f: 'g', }, ], } } h = Hash.new(obj) expected_hash = { a: 1, b: "two", c: { d: 1, }, e: [ { f: 'g', }, ], } expect(h).to eq(expected_hash) end describe '#to_n' do it 'converts a hash with native objects as values' do obj = { 'a_key' => `{ key: 1 }` } native = obj.to_n `#{native}.a_key.key`.should == 1 end it 'passes Ruby objects that cannot be converted' do object = Object.new hash = { foo: object } native = hash.to_n expect(`#{native}.foo`).to eq object end end end
Version data entries
15 entries across 15 versions & 1 rubygems