Sha256: 26e398b5f7276086123c8c01efc4221987387d5f110191d33ba7fd4c820e3db4

Contents?: true

Size: 1 KB

Versions: 10

Compression:

Stored size: 1 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Hyperdrive::Utils do
  context '.sanitize_keys' do
    before do
      @subject = Hyperdrive::Utils.sanitize_keys([:keep], { keep: 'this', remove: 'that' })
    end

    it "removes keys that were specified from the given hash" do
      @subject.key?(:remove).must_equal false
    end

    it "keeps keys that were not specified from the given hash" do
      @subject.key?(:keep).must_equal true
    end
  end

  context '.symbolize_keys' do
    before do
      @hash = { 'string' => 'cheese', 'collection' => [{'skylanders' => 155}], 'map' => { 'oceans' => 'blue' } }
      @subject = Hyperdrive::Utils.symbolize_keys(@hash)
    end

    it "can symbolize the keys of a hash" do
      @subject[:string].must_equal 'cheese'
    end

    it "can symbolize the keys of nested hashes" do
      @subject[:map][:oceans].must_equal 'blue'
    end

    it "can symbolize the keys of arrays of hashes" do
      @subject[:collection].first[:skylanders].must_equal 155
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
hyperdrive-0.0.15 spec/hyperdrive/utils_spec.rb
hyperdrive-0.0.14 spec/hyperdrive/utils_spec.rb
hyperdrive-0.0.13 spec/hyperdrive/utils_spec.rb
hyperdrive-0.0.12 spec/hyperdrive/utils_spec.rb
hyperdrive-0.0.11 spec/hyperdrive/utils_spec.rb
hyperdrive-0.0.10 spec/hyperdrive/utils_spec.rb
hyperdrive-0.0.9 spec/hyperdrive/utils_spec.rb
hyperdrive-0.0.8 spec/hyperdrive/utils_spec.rb
hyperdrive-0.0.7 spec/hyperdrive/utils_spec.rb
hyperdrive-0.0.6 spec/hyperdrive/utils_spec.rb