Sha256: 68a81c83f23360da3db9e8e05fda60549343d2d073549d45f696ec7032f7f3ef
Contents?: true
Size: 1.03 KB
Versions: 1
Compression:
Stored size: 1.03 KB
Contents
require 'spec_helper' require 'transproc/hash' describe 'Hash mapping with Transproc' do describe 'symbolize_keys' do it 'returns a new hash with symbolized keys' do symbolize_keys = Transproc(:symbolize_keys) input = { 'foo' => 'bar' } output = { foo: 'bar' } expect(symbolize_keys[input]).to eql(output) end end describe 'map' do it 'returns a new hash with applied functions' do map = Transproc(:map, 'foo' => :foo) input = { 'foo' => 'bar' } output = { foo: 'bar' } expect(map[input]).to eql(output) end end describe 'combining transformations' do it 'applies functions to the hash' do symbolize_keys = Transproc(:symbolize_keys) map = Transproc(:map, user_name: :name, user_email: :email) transformation = symbolize_keys + map input = { 'user_name' => 'Jade', 'user_email' => 'jade@doe.org' } output = { name: 'Jade', email: 'jade@doe.org' } result = transformation[input] expect(result).to eql(output) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
transproc-0.0.1 | spec/integration/hash_mapping_spec.rb |