diff options
Diffstat (limited to 'spec/support')
| -rw-r--r-- | spec/support/matchers.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/spec/support/matchers.rb b/spec/support/matchers.rb new file mode 100644 index 0000000..bb54d19 --- /dev/null +++ b/spec/support/matchers.rb @@ -0,0 +1,13 @@ +RSpec::Matchers.define :match_schema do |version: nil, **options| + match do |actual| + path = License::Management.root.join("spec/fixtures/v#{version}_schema.json") + schema = JSON.parse(IO.read(path)) + @errors = JSON::Validator.fully_validate(schema, actual, options) + @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 |
