2018-05-07 16:47:29 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2016-08-18 16:21:09 +02:00
|
|
|
# Source: https://robots.thoughtbot.com/validating-json-schemas-with-an-rspec-matcher
|
|
|
|
|
|
|
|
|
|
RSpec::Matchers.define :match_response_schema do |schema|
|
|
|
|
|
match do |json|
|
|
|
|
|
schema_directory = "#{Dir.pwd}/spec/support/schemas"
|
|
|
|
|
schema_path = "#{schema_directory}/#{schema}.json"
|
|
|
|
|
JSON::Validator.validate!(schema_path, json, strict: true)
|
|
|
|
|
end
|
|
|
|
|
end
|