summaryrefslogtreecommitdiff
path: root/spec/unit
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit')
-rw-r--r--spec/unit/license_finder/dependency_spec.rb45
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