Sha256: 8f7b3d1921c4e9acfd6af8b66588dd3494ae2abcde5d016cc29d9a0754d094fa

Contents?: true

Size: 1.22 KB

Versions: 5

Compression:

Stored size: 1.22 KB

Contents

require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'spec_helper.rb'))
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'lib', 'whiskey_disk', 'config'))
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'lib', 'whiskey_disk', 'config', 'filters', 'stringify_hash_keys_filter'))

describe 'filtering configuration data to only have symbol hash keys' do
  before do
    @config = WhiskeyDisk::Config.new
    @filter = WhiskeyDisk::Config::StringifyHashKeysFilter.new(@config)
    @data = { 
      'a' => {
        :x => 'y',
        'c' => 'd',
        :e => {
          'f' => ['a', 'b', 'c']
        }
      },
      :b => [ '1', '2', '3' ]
    }
  end
  
  it 'recursively stringifies hash keys in the provided data structure' do
    @filter.filter(@data).should == {
      'a' => {
        'x' => 'y',
        'c' => 'd',
        'e' => {
          'f' => [ 'a', 'b', 'c' ]
        }
      },
      'b' => [ '1', '2', '3' ]
    }
  end
  
  it 'clones value data so that the original data structure is not shared' do
    original = @data.clone
    result = @filter.filter(@data)
    result['a']['e']['f'] << 'd'
    @data.should == original
  end
end

Version data entries

5 entries across 5 versions & 3 rubygems

Version Path
ol-whisk_deploy-0.6.25 spec/whiskey_disk/config/filters/stringify_hash_keys_filter_spec.rb
ol-whisk_deploy-0.6.26 spec/whiskey_disk/config/filters/stringify_hash_keys_filter_spec.rb
whisk_deploy-0.6.26 spec/whiskey_disk/config/filters/stringify_hash_keys_filter_spec.rb
whiskey_disk-0.6.24 spec/whiskey_disk/config/filters/stringify_hash_keys_filter_spec.rb
whiskey_disk-0.6.23 spec/whiskey_disk/config/filters/stringify_hash_keys_filter_spec.rb