Sha256: af01f225f9a95845086dc050bc47790fd93508976ae731cad86dd2a8ee90f7da

Contents?: true

Size: 667 Bytes

Versions: 3

Compression:

Stored size: 667 Bytes

Contents

require 'spec_helper'

describe HashSerializer::Serializer do
  let(:hash) { { name: 'John' } }
  let(:indifferent_hash) { hash.with_indifferent_access }

  it 'dump' do
    expect(HashSerializer::Serializer.dump(hash)).to eq(hash.to_json)
  end

  context 'load' do
    it 'hash' do
      expect(hash).to receive(:with_indifferent_access).and_return(indifferent_hash)

      expect(HashSerializer::Serializer.load(hash)).to eq(indifferent_hash)
    end

    it 'JSON string' do
      expect(HashSerializer::Serializer.load(hash.to_json)).to eq(indifferent_hash)
    end

    it 'nil' do
      expect(HashSerializer::Serializer.load(nil)).to eq({})
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hash_serializer-0.2.0 spec/hash_serializer/serializer_spec.rb
hash_serializer-0.1.1 spec/hash_serializer/serializer_spec.rb
hash_serializer-0.1.0 spec/hash_serializer/serializer_spec.rb