Sha256: fb0b3fc3e5bdfedc324f9b4ae832bb8193e54615a3e485daefc2a701f5fff3f1

Contents?: true

Size: 1.39 KB

Versions: 1

Compression:

Stored size: 1.39 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe Array do

  describe 'recursively_symbolize_keys!' do

    it "should recursively convert a hash with string keys to a hash with symbol keys" do
      hash_symbols = {
                        :options => {
                          :verbose => false,
                        },
                          :repos => {
                             :repo1 => {:path => "something"}
                        }
                      }

      hash_strings = {
                        'options' => {
                          'verbose' => false,
                        },
                          'repos' => {
                             'repo1' => {'path' => "something"}
                        }
                      }

      hash_symbols.should == hash_strings.recursively_symbolize_keys!
    end

    it "should should handle hashes that are already symbolized" do
      hash_symbols = {
                        :options => {
                          :verbose => false,
                        },
                          :repos => {
                             :repo1 => {:path => "something"}
                        }
                      }

      hash_copy = hash_symbols.dup

      hash_copy.should == hash_symbols.recursively_symbolize_keys!
      hash_symbols[:repos][:repo1].should == {:path => "something"}
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
revenc-0.2.1 spec/basic_app/array_spec.rb