Sha256: 435364f83fa11768c0499cb762c3059d1c3ad8a2754b60518230089f7584b449

Contents?: true

Size: 1.93 KB

Versions: 3

Compression:

Stored size: 1.93 KB

Contents

# encoding=utf-8
require 'helper'

class TestLicenseeCopyrightMatchers < Minitest::Test
  should 'match the license' do
    text = 'Copyright 2015 Ben Balter'
    file = Licensee::Project::LicenseFile.new(text)
    assert_equal 'no-license', Licensee::Matchers::Copyright.new(file).match.key
  end

  should 'know the match confidence' do
    text = 'Copyright 2015 Ben Balter'
    file = Licensee::Project::LicenseFile.new(text)
    assert_equal 100, Licensee::Matchers::Copyright.new(file).confidence
  end

  should 'match Copyright (C) copyright notices' do
    text = 'Copyright (C) 2015 Ben Balter'
    file = Licensee::Project::LicenseFile.new(text)
    assert_equal 'no-license', Licensee::Matchers::Copyright.new(file).match.key
  end

  should 'match Copyright © copyright notices' do
    text = 'copyright © 2015 Ben Balter'
    file = Licensee::Project::LicenseFile.new(text)
    assert_equal 'no-license', Licensee::Matchers::Copyright.new(file).match.key
  end

  should 'not false positive' do
    text = File.open(Licensee::License.find('mit').path).read.split('---').last
    file = Licensee::Project::LicenseFile.new(text)
    assert_equal nil, Licensee::Matchers::Copyright.new(file).match
  end

  should 'handle UTF-8 encoded copyright notices' do
    text = 'Copyright (c) 2010-2014 Simon Hürlimann'
    file = Licensee::Project::LicenseFile.new(text)
    assert_equal 'no-license', Licensee::Matchers::Copyright.new(file).match.key
  end

  should 'handle ASCII-8BIT encoded copyright notices' do
    text = "Copyright \xC2\xA92015 Ben Balter`".force_encoding('ASCII-8BIT')
    file = Licensee::Project::LicenseFile.new(text)
    assert_equal 'no-license', Licensee::Matchers::Copyright.new(file).match.key
  end

  should 'match comma, separated dates' do
    text = 'Copyright (c) 2003, 2004 Ben Balter'
    file = Licensee::Project::LicenseFile.new(text)
    assert_equal 'no-license', Licensee::Matchers::Copyright.new(file).match.key
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
licensee-8.0.0 test/test_licensee_copyright_matcher.rb
licensee-7.0.1 test/test_licensee_copyright_matcher.rb
licensee-7.0.0 test/test_licensee_copyright_matcher.rb