Sha256: cd3f6a8f8c60556d9307ec941aa55db785f3cc8d8cba311e5912284311c68262

Contents?: true

Size: 842 Bytes

Versions: 3

Compression:

Stored size: 842 Bytes

Contents

require 'spec_helper'

describe ElabsMatchers::Helpers::Common 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

3 entries across 3 versions & 1 rubygems

Version Path
elabs_matchers-0.0.3 spec/elabs_matchers/helpers/common_spec.rb
elabs_matchers-0.0.2 spec/elabs_matchers/helpers/common_spec.rb
elabs_matchers-0.0.1 spec/elabs_matchers/helpers/common_spec.rb