Sha256: fb71f25d9cc1c1f937d9bae4a9ca30b21c50249a5c041c16b0cdd70105a810b8

Contents?: true

Size: 607 Bytes

Versions: 1

Compression:

Stored size: 607 Bytes

Contents

require "spec_helper"
require_relative "../../support/custom_json_serializer"

RSpec.describe CustomJsonSerializer do
  describe ".load" do
    it "deserializes, removing pairs with blank keys or values" do
      hash = { "key1" => "banana", "tkey" => nil, "" => "foo" }
      expect(described_class.load(hash.to_json)).to(eq("key1" => "banana"))
    end
  end

  describe ".dump" do
    it "serializes to JSON, removing pairs with nil values" do
      hash = { "key1" => "banana", "tkey" => nil, "" => "foo" }
      expect(described_class.dump(hash)).to(eq('{"key1":"banana","":"foo"}'))
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
paper_trail-7.1.0 spec/paper_trail/serializers/custom_json_serializer_spec.rb