Sha256: d8906d1f13abb1baab4d8d8dcafde634c17ba4cbb58b120be7f2f97e54e3a007

Contents?: true

Size: 1.13 KB

Versions: 10

Compression:

Stored size: 1.13 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'"
  }.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
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
licensee-9.6.0 spec/licensee/matchers/gemspec_matcher_spec.rb
licensee-9.5.0 spec/licensee/matchers/gemspec_matcher_spec.rb
licensee-9.4.0 spec/licensee/matchers/gemspec_matcher_spec.rb
licensee-9.3.1 spec/licensee/matchers/gemspec_matcher_spec.rb
licensee-9.3.0 spec/licensee/matchers/gemspec_matcher_spec.rb
licensee-9.2.1 spec/licensee/matchers/gemspec_matcher_spec.rb
licensee-9.2.0 spec/licensee/matchers/gemspec_matcher_spec.rb
licensee-9.1.0 spec/licensee/matchers/gemspec_matcher_spec.rb
licensee-9.0.0 spec/licensee/matchers/gemspec_matcher_spec.rb
licensee-9.0.0.beta.1 spec/licensee/matchers/gemspec_matcher_spec.rb