Sha256: 91cbb42ac1ae634507f0acc6df090e22fe54e28198fcc57f7fc01c0c07ddabdc
Contents?: true
Size: 1.55 KB
Versions: 1
Compression:
Stored size: 1.55 KB
Contents
require 'helper' class TestLicenseeProjectFile < Minitest::Test def setup @repo = Rugged::Repository.new(fixture_path("licenses.git")) blob = 'bcb552d06d9cf1cd4c048a6d3bf716849c2216cc' @file = Licensee::ProjectFile.new(@repo.lookup(blob), "LICENSE") @gpl = Licensee::License.find "GPL-3.0" @mit = Licensee::License.find "MIT" end should "read the file" do assert @file.contents =~ /MIT/ end should "match the license" do assert_equal "mit", @file.match.key end should "know the path" do assert_equal "LICENSE", @file.path end should "calculate confidence" do assert_equal 100, @file.confidence end should "parse the attribution" do assert_equal "Copyright (c) 2014 Ben Balter", @file.attribution end context "license filename scoring" do EXPECTATIONS = { "license" => 1.0, "LICENCE" => 1.0, "unLICENSE" => 1.0, "unlicence" => 1.0, "license.md" => 0.9, "LICENSE.md" => 0.9, "license.txt" => 0.9, "COPYING" => 0.8, "copyRIGHT" => 0.8, "COPYRIGHT.txt" => 0.8, "LICENSE.php" => 0.7, "LICENSE-MIT" => 0.5, "MIT-LICENSE.txt" => 0.5, "mit-license-foo.md" => 0.5, "README.txt" => 0.0 } EXPECTATIONS.each do |filename, expected| should "score a license named `#{filename}` as `#{expected}`" do assert_equal expected, Licensee::ProjectFile.license_score(filename) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
licensee-5.0.0 | test/test_licensee_project_file.rb |