Sha256: 1fbfca0dee6066b8b37776750b393bd9d1685f714495f18bb99e22ccdae114ee

Contents?: true

Size: 1.46 KB

Versions: 9

Compression:

Stored size: 1.46 KB

Contents

RSpec.describe Licensee::Matchers::Copyright do
  let(:content) { 'Copyright 2015 Ben Balter' }
  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 'stores the file' do
    expect(subject.file).to eql(file)
  end

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

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

  {
    'Standard'              => 'Copyright (C) 2015 Ben Balter',
    'Unicode (C)-style'     => 'Copyright © 2015 Ben Balter',
    'Symbol only'           => '(C) 2015 Ben Balter',
    'UTF-8 Encoded'         => 'Copyright (c) 2010-2014 Simon Hürlimann',
    'Comma-separated date'  => 'Copyright (c) 2003, 2004 Ben Balter',
    'Hyphen-separated date' => 'Copyright (c) 2003-2004 Ben Balter',
    'ASCII-8BIT encoded'    => "Copyright \xC2\xA92015 Ben Balter`",
    'No year'               => 'Copyright Ben Balter'
      .force_encoding('ASCII-8BIT')
  }.each do |description, notice|
    context "with a #{description} notice" do
      let(:content) { notice }

      it 'matches' do
        expect(content).to be_detected_as(no_license)
      end
    end
  end

  context 'with a license with a copyright notice' do
    let(:content) { sub_copyright_info(mit) }

    it "doesn't match" do
      expect(subject.match).to be_nil
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
licensee-9.9.0.beta.3 spec/licensee/matchers/copyright_matcher_spec.rb
licensee-9.9.0.beta.2 spec/licensee/matchers/copyright_matcher_spec.rb
licensee-9.8.0 spec/licensee/matchers/copyright_matcher_spec.rb
licensee-9.7.0 spec/licensee/matchers/copyright_matcher_spec.rb
licensee-9.6.0 spec/licensee/matchers/copyright_matcher_spec.rb
licensee-9.5.0 spec/licensee/matchers/copyright_matcher_spec.rb
licensee-9.4.0 spec/licensee/matchers/copyright_matcher_spec.rb
licensee-9.3.1 spec/licensee/matchers/copyright_matcher_spec.rb
licensee-9.3.0 spec/licensee/matchers/copyright_matcher_spec.rb