Sha256: 83dc45e44925b635d1d80ab916a2079ee08f9e9d9f237cebe165224d0c5105b7

Contents?: true

Size: 995 Bytes

Versions: 1

Compression:

Stored size: 995 Bytes

Contents

# frozen_string_literal: true

RSpec.describe Licensee::Matchers::Spdx do
  let(:content) { 'PackageLicenseDeclared: MIT' }
  let(:file) do
    Licensee::ProjectFiles::LicenseFile.new(content, 'LICENSE.spdx')
  end
  let(:mit) { Licensee::License.find('mit') }
  let(:other) { Licensee::License.find('other') }
  subject { described_class.new(file) }

  it 'matches' do
    expect(subject.match).to eql(mit)
  end

  it 'has a confidence' do
    expect(subject.confidence).to eql(90)
  end

  context 'no license field' do
    let(:content) { 'foo: bar' }

    it 'returns nil' do
      expect(subject.match).to be_nil
    end
  end

  context 'an unknown license' do
    let(:content) { 'PackageLicenseDeclared: xyz' }

    it 'returns other' do
      expect(subject.match).to eql(other)
    end
  end

  context 'a license expression' do
    let(:content) { 'PackageLicenseDeclared: (MIT OR Apache-2.0)' }

    it 'returns other' do
      expect(subject.match).to eql(other)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
licensee-9.12.0 spec/licensee/matchers/spdx_matcher_spec.rb