lib/service_contract/assertions.rb in service_contract-0.1.1 vs lib/service_contract/assertions.rb in service_contract-0.2.0

- old
+ new

@@ -14,9 +14,13 @@ elsif type.complex? # type should have fields type.fields.each do |field| + #Does data contain attributes that the contract doesn't specify? + data_extra_attrs = (data.keys.map(&:to_sym) - type.fields.map{|n| n.name.to_sym}) + assert_equal 0, data_extra_attrs.size, "#{type.name} contains attributes not described in contract: #{data_extra_attrs.join(',')}" + # ensure the field is present value = data.fetch(field.name) do data.fetch(field.name.to_sym) do assert false, "expected #{type.name} to have attribute: #{field.name}" end \ No newline at end of file