Sha256: 3a4638b021094c35a1885082a4c665663ce13647ec38d58ce2e4b131ae53ee3b

Contents?: true

Size: 701 Bytes

Versions: 1

Compression:

Stored size: 701 Bytes

Contents

require 'spec_helper'

describe HashCast do

  describe ".create" do
    it "should cast hash attributes" do
      input_hash = {
        contact: {
          name: "John Smith",
          age:  22,
          company: {
            name: "MyCo",
          }
        }
      }

      caster = HashCast.create do
        hash :contact do
          string   :name
          integer  :age
          hash :company do
            string :name
          end
        end

        def registered?
          true
        end
      end

      casted_hash = caster.cast(input_hash)

      expect(casted_hash.object_id).to_not eq(input_hash.object_id)
      expect(casted_hash).to eq(input_hash)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hash_cast-0.5.2 spec/hash_cast/hash_cast_spec.rb