Sha256: 159938cc518dd6e1cd155e6629f2e756ad3a6fa40911661c2e9ed4dc3817d438
Contents?: true
Size: 1.28 KB
Versions: 10
Compression:
Stored size: 1.28 KB
Contents
RSpec.describe Licensee::Matchers::NpmBower 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 { 'double quotes' => '"license": "mit"', 'single quotes' => "'license': 'mit'", 'mixed quotes' => "'license': \"mit\"", '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
10 entries across 10 versions & 1 rubygems