diff options
| -rw-r--r-- | spec/fixtures/schema/v2.0.json (renamed from spec/fixtures/v2.0_schema.json) | 4 | ||||
| -rw-r--r-- | spec/fixtures/schema/v2.0_dependency.json | 27 | ||||
| -rw-r--r-- | spec/integration/python/pipenv_spec.rb | 1 | ||||
| -rw-r--r-- | spec/integration/ruby/bundler_spec.rb | 2 | ||||
| -rw-r--r-- | spec/support/matchers.rb | 9 |
5 files changed, 37 insertions, 6 deletions
diff --git a/spec/fixtures/v2.0_schema.json b/spec/fixtures/schema/v2.0.json index bd304ce..3377a9d 100644 --- a/spec/fixtures/v2.0_schema.json +++ b/spec/fixtures/schema/v2.0.json @@ -1,5 +1,5 @@ { - "$id": "https://gitlab.com/gitlab-org/security-products/license-management/blob/master/spec/fixtures/v2.0_schema.json", + "$id": "https://gitlab.com/gitlab-org/security-products/license-management/blob/master/spec/fixtures/schema/v2.0.json", "type": "object", "required": [ "version", @@ -9,7 +9,7 @@ "properties": { "version": { "type": "string" }, "licenses": { "type": "array" }, - "dependencies": { "type": "array" } + "dependencies": { "$ref": "v2.0_dependency.json" } }, "additionalProperties": false } diff --git a/spec/fixtures/schema/v2.0_dependency.json b/spec/fixtures/schema/v2.0_dependency.json new file mode 100644 index 0000000..fcd96d7 --- /dev/null +++ b/spec/fixtures/schema/v2.0_dependency.json @@ -0,0 +1,27 @@ +{ + "type": "array", + "required": [ + "name", + "url", + "description", + "paths", + "licenses" + ], + "properties": { + "name": { "type": "string" }, + "url": { "type": "uri" }, + "description": { "type": "string" }, + "paths": { + "type": "array", + "items": { + "type": "string" + } + }, + "licenses": { + "type": "array", + "items": { + "type": "string" + } + } + } +} diff --git a/spec/integration/python/pipenv_spec.rb b/spec/integration/python/pipenv_spec.rb index 6039b25..2756f6b 100644 --- a/spec/integration/python/pipenv_spec.rb +++ b/spec/integration/python/pipenv_spec.rb @@ -23,6 +23,7 @@ RSpec.describe "pipenv" do report = runner.scan expect(report).not_to be_empty + expect(report).to match_schema(version: '2.0') expect(report[:version]).not_to be_empty expect(report[:licenses]).not_to be_empty expect(report[:dependencies].map { |x| x[:name] }).to include("six") diff --git a/spec/integration/ruby/bundler_spec.rb b/spec/integration/ruby/bundler_spec.rb index 179da2a..2cb8f7d 100644 --- a/spec/integration/ruby/bundler_spec.rb +++ b/spec/integration/ruby/bundler_spec.rb @@ -14,6 +14,7 @@ gem 'saml-kit' report = runner.scan expect(report).not_to be_empty + expect(report).to match_schema(version: '2.0') expect(report[:licenses]).not_to be_empty expect(report[:dependencies].map { |x| x[:name] }).to include("saml-kit") end @@ -81,6 +82,7 @@ BUNDLED WITH report = runner.scan expect(report).not_to be_empty + expect(report).to match_schema(version: '2.0') expect(report[:licenses]).not_to be_empty expect(report[:dependencies].map { |x| x[:name] }).to include("saml-kit") end diff --git a/spec/support/matchers.rb b/spec/support/matchers.rb index bb54d19..1d1c263 100644 --- a/spec/support/matchers.rb +++ b/spec/support/matchers.rb @@ -1,8 +1,9 @@ -RSpec::Matchers.define :match_schema do |version: nil, **options| +RSpec::Matchers.define :match_schema do |version: '2.0'| 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) + schema = License::Management.root + .join("spec/fixtures/schema/v#{version}.json") + .to_s + @errors = JSON::Validator.fully_validate(schema, actual) @errors.empty? end |
