Sha256: 14777585c09437e0e2a9d0961545565fd30c17d1299a2bdabacbfaa9d213df83

Contents?: true

Size: 1.3 KB

Versions: 2

Compression:

Stored size: 1.3 KB

Contents

require "spec_helper"

describe Hash do
  context "camelize_keys" do
    subject{ {:first_name => "nicolas"} }
    it "should camelize keys" do
      expect(subject.camelize_keys).to eq :firstName => "nicolas"
    end
    it "should not destruct original hash" do
      subject.camelize_keys
      expect(subject).to eq :first_name => "nicolas"
    end
  end
  context "camelize_keys!" do
    subject{ {:first_name => "nicolas"} }
    it "should camelize keys" do
      expect(subject.camelize_keys!).to eq :firstName => "nicolas"
    end
    it "should destruct original hash" do
      subject.camelize_keys!
      expect(subject).to eq :firstName => "nicolas"
    end
  end
  context "underscore_keys"  do
    subject { {:firstName => "nicolas"} }
    it "should underscore keys" do
      expect(subject.underscore_keys).to eq :first_name => "nicolas"
    end
    it "should not destruct original hash" do
      subject.underscore_keys
      expect(subject).to eq :firstName => "nicolas"
    end
  end
  context "underscore_keys!" do
    subject { {:firstName => "nicolas"} }
    it "should underscore keys" do
      expect(subject.underscore_keys!).to eq :first_name => "nicolas"
    end
    it "should destruct original hash" do
      subject.underscore_keys!
      expect(subject).to eq :first_name => "nicolas"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lemonway-1.0.1 spec/hash_spec.rb
lemonway-1.0.0 spec/hash_spec.rb