From 3aeed26912b238f6cb9c8b43587b0f3a7bf181f4 Mon Sep 17 00:00:00 2001 From: mo khan Date: Wed, 15 Jan 2020 14:19:39 -0700 Subject: Add spec to ensure we can parse a v3 Pipfile.lock --- spec/support/matchers.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 spec/support/matchers.rb (limited to 'spec/support') 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 -- cgit v1.2.3