blob: d4642d4564883deaf64aed4c8d1204bcb449d9d6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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
|