Sha256: 475f4d11242092b173ec6ae5265968d0a9641f1f9d5e2e52e0f06d641faed63d

Contents?: true

Size: 1.42 KB

Versions: 4

Compression:

Stored size: 1.42 KB

Contents

require 'helper'

class TestLicenseeCopyrightMatcher < Minitest::Test

  def setup
    text = "Copyright 2015 Ben Balter"
    blob = FakeBlob.new(text)
    @file = Licensee::LicenseFile.new(blob)
  end

  should "match the license" do
    assert_equal "no-license", Licensee::CopyrightMatcher.match(@file).key
  end

  should "know the match confidence" do
    assert_equal 100, Licensee::CopyrightMatcher.new(@file).confidence
  end

  should "match Copyright (C) copyright notices" do
    text = "Copyright (C) 2015 Ben Balter"
    blob = FakeBlob.new(text)
    file = Licensee::LicenseFile.new(blob)
    assert_equal "no-license", Licensee::CopyrightMatcher.match(file).key
  end

  should "match Copyright © copyright notices" do
    text = "copyright © 2015 Ben Balter"
    blob = FakeBlob.new(text)
    file = Licensee::LicenseFile.new(blob)
    assert_equal "no-license", Licensee::CopyrightMatcher.match(file).key
  end

  should "not false positive" do
    text = File.open(Licensee::Licenses.find("mit").path).read.split("---").last
    blob = FakeBlob.new(text)
    file = Licensee::LicenseFile.new(blob)
    assert_equal nil, Licensee::CopyrightMatcher.match(file)
  end

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
licensee-4.7.2 test/test_licensee_copyright_matcher.rb
licensee-4.7.1 test/test_licensee_copyright_matcher.rb
licensee-4.7.0 test/test_licensee_copyright_matcher.rb
licensee-4.6.0 test/test_licensee_copyright_matcher.rb