Sha256: 00f2173a190b6231bda521a150c51061e79a931019f595b8d50f11a3ee1e5bcc

Contents?: true

Size: 1.81 KB

Versions: 11

Compression:

Stored size: 1.81 KB

Contents

RSpec.describe Licensee::ProjectFiles::PackageManagerFile do
  let(:content) { '' }
  let(:filename) { '' }
  subject { described_class.new(content, filename) }

  context 'name scoring' do
    {
      'licensee.gemspec' => 1.0,
      'test.cabal'       => 1.0,
      'package.json'     => 1.0,
      'DESCRIPTION'      => 0.9,
      'dist.ini'         => 0.8,
      'bower.json'       => 0.75,
      'README.md'        => 0.0
    }.each do |filename, expected_score|
      context "a file named #{filename}" do
        let(:score) { described_class.name_score(filename) }
        it 'scores the file' do
          expect(score).to eql(expected_score)
        end
      end
    end
  end

  context 'matchers' do
    let(:possible_matchers) { subject.possible_matchers }

    context 'with a gemspec ' do
      let(:filename) { 'project.gemspec' }

      it 'returns the gemspec matcher' do
        expect(possible_matchers).to eql([Licensee::Matchers::Gemspec])
      end
    end

    context 'with cabal file ' do
      let(:filename) { 'test.cabal' }

      it 'returns the cabal matcher' do
        expect(possible_matchers).to eql([Licensee::Matchers::Cabal])
      end
    end

    context 'with package.json' do
      let(:filename) { 'package.json' }

      it 'returns the gemspec matcher' do
        expect(possible_matchers).to eql([Licensee::Matchers::NpmBower])
      end
    end

    context 'with dist.ini' do
      let(:filename) { 'dist.ini' }

      it 'returns the DistZilla matcher' do
        expect(possible_matchers).to eql([Licensee::Matchers::DistZilla])
      end
    end

    context 'with DESCRIPTION' do
      let(:filename) { 'DESCRIPTION' }
      let(:content) { 'Package: test' }

      it 'returns the Cran matcher' do
        expect(possible_matchers).to eql([Licensee::Matchers::Cran])
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
licensee-9.7.0 spec/licensee/project_files/package_info_spec.rb
licensee-9.6.0 spec/licensee/project_files/package_info_spec.rb
licensee-9.5.0 spec/licensee/project_files/package_info_spec.rb
licensee-9.4.0 spec/licensee/project_files/package_info_spec.rb
licensee-9.3.1 spec/licensee/project_files/package_info_spec.rb
licensee-9.3.0 spec/licensee/project_files/package_info_spec.rb
licensee-9.2.1 spec/licensee/project_files/package_info_spec.rb
licensee-9.2.0 spec/licensee/project_files/package_info_spec.rb
licensee-9.1.0 spec/licensee/project_files/package_info_spec.rb
licensee-9.0.0 spec/licensee/project_files/package_info_spec.rb
licensee-9.0.0.beta.1 spec/licensee/project_files/package_info_spec.rb