summaryrefslogtreecommitdiff
path: root/spec/support
diff options
context:
space:
mode:
authormo khan <mo.khan@gmail.com>2020-01-15 14:19:39 -0700
committermo khan <mo.khan@gmail.com>2020-01-15 15:03:09 -0700
commit3aeed26912b238f6cb9c8b43587b0f3a7bf181f4 (patch)
tree27bc5cef8453df5f019f6146f26b4e0d346e1a40 /spec/support
parent0045121115a0fdad70ca30f4a1e046e53986e02c (diff)
Add spec to ensure we can parse a v3 Pipfile.lock
Diffstat (limited to 'spec/support')
-rw-r--r--spec/support/matchers.rb13
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