Sha256: 3e03d37b5508185bdcb065b496f3bdf784a786873b1b04402fc5ca1f2af7824e

Contents?: true

Size: 1.11 KB

Versions: 22

Compression:

Stored size: 1.11 KB

Contents

RSpec.describe Licensee::Matchers::Cabal do
  let(:content) { 'license: mit' }
  let(:file) { Licensee::ProjectFiles::LicenseFile.new(content, 'LICENSE.txt') }
  let(:mit) { Licensee::License.find('mit') }
  let(:no_license) { Licensee::License.find('no-license') }
  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

  {
    'whitespace'         => 'license : mit',
    'no whitespace'      => 'license:mit',
    'leading whitespace' => ' license:mit'
  }.each do |description, license_declaration|
    context "with a #{description} declaration" do
      let(:content) { license_declaration }

      it 'matches' do
        expect(subject.match).to eql(mit)
      end
    end
  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) { 'license: foo' }

    it 'returns other' do
      expect(subject.match).to eql(Licensee::License.find('other'))
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
licensee-9.11.0 spec/licensee/matchers/cabal_matcher_spec.rb
licensee-9.10.1 spec/licensee/matchers/cabal_matcher_spec.rb
licensee-9.10.0 spec/licensee/matchers/cabal_matcher_spec.rb
licensee-9.9.4 spec/licensee/matchers/cabal_matcher_spec.rb
licensee-9.9.3 spec/licensee/matchers/cabal_matcher_spec.rb
licensee-9.9.2 spec/licensee/matchers/cabal_matcher_spec.rb
licensee-9.9.1 spec/licensee/matchers/cabal_matcher_spec.rb
licensee-9.9.0 spec/licensee/matchers/cabal_matcher_spec.rb
licensee-9.9.0.beta.3 spec/licensee/matchers/cabal_matcher_spec.rb
licensee-9.9.0.beta.2 spec/licensee/matchers/cabal_matcher_spec.rb
licensee-9.8.0 spec/licensee/matchers/cabal_matcher_spec.rb
licensee-9.7.0 spec/licensee/matchers/cabal_matcher_spec.rb
licensee-9.6.0 spec/licensee/matchers/cabal_matcher_spec.rb
licensee-9.5.0 spec/licensee/matchers/cabal_matcher_spec.rb
licensee-9.4.0 spec/licensee/matchers/cabal_matcher_spec.rb
licensee-9.3.1 spec/licensee/matchers/cabal_matcher_spec.rb
licensee-9.3.0 spec/licensee/matchers/cabal_matcher_spec.rb
licensee-9.2.1 spec/licensee/matchers/cabal_matcher_spec.rb
licensee-9.2.0 spec/licensee/matchers/cabal_matcher_spec.rb
licensee-9.1.0 spec/licensee/matchers/cabal_matcher_spec.rb