summaryrefslogtreecommitdiff
path: root/spec/support/matchers.rb
blob: 1d1c263daeb8b61c7ff2efa29c5fa991c8c580f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
RSpec::Matchers.define :match_schema do |version: '2.0'|
  match do |actual|
    schema = License::Management.root
      .join("spec/fixtures/schema/v#{version}.json")
      .to_s
    @errors = JSON::Validator.fully_validate(schema, actual)
    @errors.empty?
  end

  failure_message do |response|
    "didn't match the schema for version #{version}" \
    " The validation errors were:\n#{@errors.join("\n")}"
  end
end