Sha256: 87742a077dba20a6f655012635e408e925b808ff689f802ce879fa019d26c7f2

Contents?: true

Size: 995 Bytes

Versions: 14

Compression:

Stored size: 995 Bytes

Contents

# frozen_string_literal: true

RSpec.describe Licensee::Matchers::Spdx do
  subject { described_class.new(file) }

  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') }

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

  it 'has a confidence' do
    expect(subject.confidence).to be(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

14 entries across 14 versions & 1 rubygems

Version Path
licensee-9.18.0 spec/licensee/matchers/spdx_matcher_spec.rb
licensee-9.17.1 spec/licensee/matchers/spdx_matcher_spec.rb
licensee-9.17.0 spec/licensee/matchers/spdx_matcher_spec.rb
licensee-9.16.1 spec/licensee/matchers/spdx_matcher_spec.rb
licensee-9.16.0 spec/licensee/matchers/spdx_matcher_spec.rb
licensee-9.15.3 spec/licensee/matchers/spdx_matcher_spec.rb
licensee-9.15.2 spec/licensee/matchers/spdx_matcher_spec.rb
licensee-9.15.1 spec/licensee/matchers/spdx_matcher_spec.rb
licensee-9.15.0 spec/licensee/matchers/spdx_matcher_spec.rb
licensee-9.14.1 spec/licensee/matchers/spdx_matcher_spec.rb
licensee-9.14.0 spec/licensee/matchers/spdx_matcher_spec.rb
licensee-9.13.2 spec/licensee/matchers/spdx_matcher_spec.rb
licensee-9.13.1 spec/licensee/matchers/spdx_matcher_spec.rb
licensee-9.13.0 spec/licensee/matchers/spdx_matcher_spec.rb