diff options
| author | Can Eldem <celdem@gitlab.com> | 2020-10-06 15:46:42 +0000 |
|---|---|---|
| committer | Can Eldem <celdem@gitlab.com> | 2020-10-06 15:46:42 +0000 |
| commit | 561d687c4753fb1ee8724d5681defa4e1ca74a6d (patch) | |
| tree | 7d0439ecc4f48b8247fd0c645da728976779dee0 /spec/unit | |
| parent | 7fe70519010e24fa1d6735b108793987e8a24aa4 (diff) | |
| parent | 20b6b06141803d9cb93713257c874ff10509fd52 (diff) | |
Merge branch 'composite-licenses' into 'master'v3.27.0
Parse composite license expressions
See merge request gitlab-org/security-products/license-management!228
Diffstat (limited to 'spec/unit')
| -rw-r--r-- | spec/unit/license_finder/dependency_spec.rb | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/spec/unit/license_finder/dependency_spec.rb b/spec/unit/license_finder/dependency_spec.rb new file mode 100644 index 0000000..d4642d4 --- /dev/null +++ b/spec/unit/license_finder/dependency_spec.rb @@ -0,0 +1,45 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe LicenseFinder::Dependency do + describe "#licenses" do + subject { described_class.new('bundler', 'example', '0.1.0', { spec_licenses: declared_licenses }).licenses } + + context "when the declared licenses is a single known license" do + let(:declared_licenses) { ['MIT'] } + + specify { expect(subject.map(&:short_name)).to match_array(['MIT']) } + end + + context "when the declared licenses is a many known licenses" do + let(:declared_licenses) { ['MIT', 'Apache-2.0'] } + + specify { expect(subject.map(&:short_name)).to match_array(%w[MIT Apache2]) } + end + + context "when the declared licenses is x OR y" do + let(:declared_licenses) { ['MIT OR Apache-2.0'] } + + specify { expect(subject.map(&:short_name)).to match_array(%w[MIT Apache2]) } + end + + context "when the declared licenses is x OR y OR z" do + let(:declared_licenses) { ['(BSD-2-Clause OR MIT OR Apache-2.0)'] } + + specify { expect(subject.map(&:short_name)).to match_array(%w[SimplifiedBSD MIT Apache2]) } + end + + context "when the declared licenses is x AND y" do + let(:declared_licenses) { ['MIT AND Apache-2.0'] } + + specify { expect(subject.map(&:short_name)).to match_array(%w[MIT Apache2]) } + end + + context "when the declared licenses is x WITH exception" do + let(:declared_licenses) { ['Apache-2.0 WITH LLVM-exception'] } + + specify { expect(subject.map(&:short_name)).to match_array(%w[Apache2 LLVM-exception]) } + end + end +end |
