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

Version Path
json-serializer-0.0.9 test/root.rb
json-serializer-0.0.8 test/root.rb
json-serializer-0.0.7 test/root.rb
json-serializer-0.0.6 test/root.rb
json-serializer-0.0.5 test/root.rb
json-serializer-0.0.4 test/root.rb
json-serializer-0.0.3 test/root.rb