Sha256: 3c8129d455af2c600e20bc8ddaf12750b07e64535317ccc89af3b4e0c41837b4

Contents?: true

Size: 1.62 KB

Versions: 10

Compression:

Stored size: 1.62 KB

Contents

# frozen_string_literal: true

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

  let(:mit) { Licensee::License.find('mit') }
  let(:gpl2) { Licensee::License.find('gpl-2.0') }
  let(:gpl3) { Licensee::License.find('gpl-3.0') }
  let(:content) { "License: MIT + file LICENSE\nPackage: test" }
  let(:file) { Licensee::ProjectFiles::LicenseFile.new(content, 'DESCRIPTION') }

  it 'stores the file' do
    expect(subject.file).to eql(file)
  end

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

  it 'is confident' do
    expect(subject.confidence).to be(90)
  end

  {
    'MIT'                      => Licensee::License.find('mit'),
    'MIT + file LICENSE'       => Licensee::License.find('mit'),
    'GPL (>=2)'                => Licensee::License.find('gpl-2.0'),
    'GPL( >= 2 )'              => Licensee::License.find('gpl-2.0'),
    'GPL (>=2) + file LICENSE' => Licensee::License.find('gpl-2.0'),
    'GPL (>=3)'                => Licensee::License.find('gpl-3.0'),
    'GPL-2'                    => Licensee::License.find('gpl-2.0'),
    'GPL-3'                    => Licensee::License.find('gpl-3.0'),
    'Foo'                      => Licensee::License.find('other')
  }.each do |license_declaration, license|
    context "with '#{license_declaration}' declaration" do
      let(:content) { "Package: test\nLicense: #{license_declaration}" }

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

  context 'with no license field' do
    let(:content) { 'Package: test' }

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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
licensee-9.16.0 spec/licensee/matchers/cran_matcher_spec.rb
licensee-9.15.3 spec/licensee/matchers/cran_matcher_spec.rb
licensee-9.15.2 spec/licensee/matchers/cran_matcher_spec.rb
licensee-9.15.1 spec/licensee/matchers/cran_matcher_spec.rb
licensee-9.15.0 spec/licensee/matchers/cran_matcher_spec.rb
licensee-9.14.1 spec/licensee/matchers/cran_matcher_spec.rb
licensee-9.14.0 spec/licensee/matchers/cran_matcher_spec.rb
licensee-9.13.2 spec/licensee/matchers/cran_matcher_spec.rb
licensee-9.13.1 spec/licensee/matchers/cran_matcher_spec.rb
licensee-9.13.0 spec/licensee/matchers/cran_matcher_spec.rb