test/assertions_test.rb in service_contract-0.3.0 vs test/assertions_test.rb in service_contract-0.4.0

- old
+ new

@@ -76,6 +76,35 @@ assert !failure_data.nil? assert failure_data.to_s.include?("not described in contract: bogus_param") end -end \ No newline at end of file + def test_enum_values + service = SampleService.find(2) + assert service, "expect to find a service by version" + + protocol = service.protocol("social_login") + endpoint = protocol.endpoint("index") + + data = [ + {token: "sometoken", provider: "facebook"}, + {token: "anothertoken", provider: "linkedin"} + ] + + assert_endpoint_response(data, endpoint) + + # test can be nil + bad_data = [ + {token: "sometoken", provider: "bad provider"} + ] + failure_data = nil + begin + assert_endpoint_response(bad_data, endpoint) + rescue Minitest::Assertion => failure + failure_data = failure + end + + assert !failure_data.nil? + assert failure_data.to_s.include?("is not an allowed value"), failure_data + end + +end