Sha256: 8e4afc5735dfcaa41e4ddd036767c27d0b5fc95fc44651ddffdb7d109eb67f7e

Contents?: true

Size: 849 Bytes

Versions: 8

Compression:

Stored size: 849 Bytes

Contents

require "spec_helper"

describe ElabsMatchers::Helpers::NormalizeKeys do
  describe "normalize_keys" do
    it "turns the keys into symbols" do
      normalize_keys("First name" => "Adam").keys.first.should == "first_name"
    end

    it "turns paramaterizes the key with _ as seperator" do
      normalize_keys("First name" => "Adam").keys.first.should == "first_name"
    end

    it "doesn't change the values" do
      normalize_keys("First name" => "Adam").values.first.should == "Adam"
    end

    it "turns the hash into a HashWithIndifferentAccess" do
      normalize_keys("First name" => "Adam").class.should == HashWithIndifferentAccess
    end

    it "works with several pairs" do
      normalize_keys("First name" => "Douglas", "Last name" => "Adams").should == { "first_name" => "Douglas", "last_name" => "Adams" }
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
elabs_matchers-2.0.1 spec/elabs_matchers/helpers/normalize_keys_spec.rb
elabs_matchers-2.0.0 spec/elabs_matchers/helpers/normalize_keys_spec.rb
elabs_matchers-1.0.1 spec/elabs_matchers/helpers/normalize_keys_spec.rb
elabs_matchers-1.0.0 spec/elabs_matchers/helpers/normalize_keys_spec.rb
elabs_matchers-0.0.7 spec/elabs_matchers/helpers/normalize_keys_spec.rb
elabs_matchers-0.0.6 spec/elabs_matchers/helpers/normalize_keys_spec.rb
elabs_matchers-0.0.5 spec/elabs_matchers/helpers/normalize_keys_spec.rb
elabs_matchers-0.0.4 spec/elabs_matchers/helpers/normalize_keys_spec.rb