lib/restspec/schema/schema_example.rb in restspec-0.2.6 vs lib/restspec/schema/schema_example.rb in restspec-0.3.0

- old
+ new

@@ -13,18 +13,28 @@ end # It returns the generated example. # @return [Restspec::Values::SuperHash] generated example. def value - attributes.inject({}) do |sample, (_, attribute)| + example_attributes = attributes.inject({}) do |sample, (_, attribute)| sample.merge(attribute.name => AttributeExample.new(attribute).value) end.merge(extensions) + + if schema.root? + wrap_in_root(example_attributes) + else + example_attributes + end end private def attributes schema.attributes_for_intention + end + + def wrap_in_root(hash) + { schema.root_name => hash } end end end end