blob: 937b7cf0e9683f6d0deb8e5ea4927b51670f448d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
# frozen_string_literal: true
RSpec::Matchers.define :match_schema do |version: '2.0'|
def schema_for(version)
Spandx::Gitlab.root.join("spec/fixtures/schema/v#{version}.json").to_s
end
match do |actual|
!actual.nil? && (@errors = JSON::Validator.fully_validate(schema_for(version), actual.to_h)).empty?
end
failure_message do |_response|
"didn't match the schema for version #{version}" \
" The validation errors were:\n#{@errors.join("\n")}"
end
end
|