2017-06-06 13:35:28 -04:00
|
|
|
def schema_path(schema)
|
|
|
|
schema_directory = "#{Dir.pwd}/spec/fixtures/api/schemas"
|
|
|
|
"#{schema_directory}/#{schema}.json"
|
|
|
|
end
|
|
|
|
|
2016-08-16 10:13:21 -04:00
|
|
|
RSpec::Matchers.define :match_response_schema do |schema, **options|
|
2016-08-01 14:41:30 -04:00
|
|
|
match do |response|
|
2017-06-06 13:35:28 -04:00
|
|
|
JSON::Validator.validate!(schema_path(schema), response.body, options)
|
|
|
|
end
|
|
|
|
end
|
2016-08-01 14:41:30 -04:00
|
|
|
|
2017-06-06 13:35:28 -04:00
|
|
|
RSpec::Matchers.define :match_schema do |schema, **options|
|
|
|
|
match do |data|
|
|
|
|
JSON::Validator.validate!(schema_path(schema), data, options)
|
2016-08-01 14:41:30 -04:00
|
|
|
end
|
|
|
|
end
|