gitlab-org--gitlab-foss/spec/support/api/schema_matcher.rb
2016-08-17 12:58:58 -03:00

9 lines
332 B
Ruby

RSpec::Matchers.define :match_response_schema do |schema, options = {}|
match do |response|
schema_directory = "#{Dir.pwd}/spec/fixtures/api/schemas"
schema_path = "#{schema_directory}/#{schema}.json"
list = options.fetch(:array, false)
JSON::Validator.validate!(schema_path, response.body, list: list)
end
end