Sha256: 18432a9a1c854faded17958369fc432ff3ea4a33483f46f9cc2376c4aa4c30aa

Contents?: true

Size: 1.37 KB

Versions: 2

Compression:

Stored size: 1.37 KB

Contents

require "spec_helper"

describe Hash do
  context "camelize_keys" do
    before do
      @hash = {:first_name => "nicolas"}
      @result_hash = @hash.camelize_keys
    end
    it "should camelize keys" do
      @result_hash.should == {:firstName => "nicolas"}
    end
    it "should not destruct original hash" do
      @hash.should == {:first_name => "nicolas"}
    end
  end
  context "camelize_keys!" do
    before do
      @hash = {:first_name => "nicolas"}
      @result_hash = @hash.camelize_keys!
    end
    it "should camelize keys" do
      @result_hash.should == {:firstName => "nicolas"}
    end
    it "should destruct original hash" do
      @hash.should == {:firstName => "nicolas"}
    end
  end
  context "underscore_keys"  do
    before do
      @hash = {:firstName => "nicolas"}
      @result_hash = @hash.underscore_keys
    end
    it "should underscore keys" do
      @result_hash.should == {:first_name => "nicolas"}
    end
    it "should not destruct original hash" do
      @hash.should == {:firstName => "nicolas"}
    end
  end
  context "underscore_keys!" do
    before do
      @hash = {:firstName => "nicolas"}
      @result_hash = @hash.underscore_keys!
    end
    it "should underscore keys" do
      @result_hash.should == {:first_name => "nicolas"}
    end
    it "should destruct original hash" do
      @hash.should == {:first_name => "nicolas"}
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lemon_way-0.0.3 spec/hash_spec.rb
lemon_way-0.0.2 spec/hash_spec.rb