schema_matcher.rb 286 Bytes
Newer Older
1
RSpec::Matchers.define :match_response_schema do |schema, **options|
2 3 4 5
  match do |response|
    schema_directory = "#{Dir.pwd}/spec/fixtures/api/schemas"
    schema_path = "#{schema_directory}/#{schema}.json"

6
    JSON::Validator.validate!(schema_path, response.body, options)
7 8
  end
end