Sha256: 788072cfa2c47b142747f0f7740e579ef4b14a868574ebd396eba30ae028311e

Contents?: true

Size: 1.45 KB

Versions: 12

Compression:

Stored size: 1.45 KB

Contents

RSpec.describe Licensee::Matchers::Gemspec do
  let(:mit) { Licensee::License.find('mit') }
  let(:content) { "s.license = 'mit'" }
  let(:file) do
    Licensee::ProjectFiles::LicenseFile.new(content, 'project.gemspec')
  end
  subject { described_class.new(file) }

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

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

  {
    'as spec.'      => "spec.license = 'mit'",
    'double quotes' => 's.license = "mit"',
    'no whitespace' => "s.license='mit'",
    'uppercase'     => "s.license = 'MIT'",
    'array'         => "s.licenses = ['mit']",
    'frozen'        => "s.license = 'mit'.freeze"
  }.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) { "s.foo = 'bar'" }

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

  context 'an unknown license' do
    let(:content) { "s.license = 'foo'" }

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

  context 'a licenses property with multiple licenses' do
    let(:content) { "s.licenses = ['mit', 'bsd-3-clause']" }

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

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
licensee-9.11.0 spec/licensee/matchers/gemspec_matcher_spec.rb
licensee-9.10.1 spec/licensee/matchers/gemspec_matcher_spec.rb
licensee-9.10.0 spec/licensee/matchers/gemspec_matcher_spec.rb
licensee-9.9.4 spec/licensee/matchers/gemspec_matcher_spec.rb
licensee-9.9.3 spec/licensee/matchers/gemspec_matcher_spec.rb
licensee-9.9.2 spec/licensee/matchers/gemspec_matcher_spec.rb
licensee-9.9.1 spec/licensee/matchers/gemspec_matcher_spec.rb
licensee-9.9.0 spec/licensee/matchers/gemspec_matcher_spec.rb
licensee-9.9.0.beta.3 spec/licensee/matchers/gemspec_matcher_spec.rb
licensee-9.9.0.beta.2 spec/licensee/matchers/gemspec_matcher_spec.rb
licensee-9.8.0 spec/licensee/matchers/gemspec_matcher_spec.rb
licensee-9.7.0 spec/licensee/matchers/gemspec_matcher_spec.rb