Sha256: 538dd98bd58242fd3c2c175702ce4648ea205d7c29b70e6da78400f2ac17fa9c
Contents?: true
Size: 505 Bytes
Versions: 7
Compression:
Stored size: 505 Bytes
Contents
require_relative "helper" Person = OpenStruct class PersonSerializer < JsonSerializer attribute :name end setup do Person.new(name: "sonny") end test "serialized object includes root" do |person| result = { person: person.to_h }.to_json assert_equal result, PersonSerializer.new(person).to_json(root: :person) end test "serialized array includes root" do |person| result = { people: [person.to_h] }.to_json assert_equal result, PersonSerializer.new([person]).to_json(root: :people) end
Version data entries
7 entries across 7 versions & 1 rubygems