spec/functional/render/schema_spec.rb in render-0.0.8 vs spec/functional/render/schema_spec.rb in render-0.0.9
- old
+ new
@@ -51,7 +51,35 @@
films = [{ id: the_id }]
schema = Schema.new(definition)
schema.serialize!(films).should == films
end
end
+
+ describe "required" do
+ # Not defined in spec, but should have been
+ it "is set with HashAttribute-level keyword" do
+ schema = Schema.new({
+ type: Object,
+ properties: {
+ name: { type: String, required: true },
+ }
+ })
+
+ schema.hash_attributes.first.required.should be
+ end
+
+ it "is set on schema-level keyword" do
+ schema = Schema.new({
+ type: Object,
+ properties: {
+ name: { type: String },
+ address: { type: String },
+ },
+ required: [:address]
+ })
+
+ schema.attributes[0].required.should_not be
+ schema.attributes[1].required.should be
+ end
+ end
end
end