diff options
| author | mo khan <mo.khan@gmail.com> | 2020-10-05 17:22:14 -0600 |
|---|---|---|
| committer | mo khan <mo.khan@gmail.com> | 2020-10-06 08:01:03 -0600 |
| commit | 4bf6440d5676bd7e120091f0a253a01e0b2fa7a3 (patch) | |
| tree | 91ebee6126a98ae1bebf46fd6e9ec12e820bf4aa /spec/unit/license_finder | |
| parent | 7fe70519010e24fa1d6735b108793987e8a24aa4 (diff) | |
Parse composite license expressions
* docs: Add changelog entry
* fix: update spec to match expected behaviour
Diffstat (limited to 'spec/unit/license_finder')
| -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 |
