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|
|
|
|
|
schema_directory = "#{Dir.pwd}/spec/fixtures/api/schemas"
|
|
|
|
schema_path = "#{schema_directory}/#{schema}.json"
|
|
|
|
|
2016-08-16 10:13:21 -04:00
|
|
|
JSON::Validator.validate!(schema_path, response.body, options)
|
2016-08-01 14:41:30 -04:00
|
|
|
end
|
|
|
|
end
|