Support JSON serialization options for model objects (#811)

This commit is contained in:
Daniel Azuma authored and GitHub committed 2019-07-29 10:40:39 -07:00
1 parent 05a1367af1
commit 75606c6ca6
2 files changed
+13 -1

No files matched your search

@@ -23,6 +23,7 @@ RSpec.describe Google::Apis::Core::JsonRepresentation do
end
let(:model_class) do
rep_class = representer_class
Class.new do
attr_accessor :unset_value
attr_accessor :nil_value
@@ -39,6 +40,8 @@ RSpec.describe Google::Apis::Core::JsonRepresentation do
attr_accessor :items
attr_accessor :child
attr_accessor :children
const_set(:Representation, rep_class)
include Google::Apis::Core::JsonObjectSupport
end
end
@@ -150,6 +153,15 @@ RSpec.describe Google::Apis::Core::JsonRepresentation do
include_examples 'it serializes'
it 'supports standard serialization from JSON gem' do
str = JSON.generate(model)
expect(str).to start_with("{\"")
end
it 'supports pretty serialization from JSON gem' do
str = JSON.pretty_generate(model)
expect(str).to start_with("{\n ")
end
end
context 'with hash' do