Sha256: 41d475b6749a21a06e9944faebce411aabef455238a2fa2f8851f4a95898c4cc

Contents?: true

Size: 1.02 KB

Versions: 3

Compression:

Stored size: 1.02 KB

Contents

require 'helper'

class TestLicenseeLevenshteinMatcher < Minitest::Test

  def setup
    text = license_from_path( Licensee::License.find("mit").path )
    blob = FakeBlob.new(text)
    @mit = Licensee::ProjectFile.new(blob, "LICENSE")
  end

  should "match the license" do
    assert_equal "mit", Licensee::LevenshteinMatcher.match(@mit).key
  end

  should "know the match confidence" do
    matcher = Licensee::LevenshteinMatcher.new(@mit)
    assert matcher.confidence > 98, "#{matcher.confidence} < 98"
  end

  should "calculate max delta" do
    assert_equal 937.8000000000001, Licensee::LevenshteinMatcher.new(@mit).max_delta
  end

  should "calculate length delta" do
    isc = Licensee::License.find("isc")
    assert_equal 0.0, Licensee::LevenshteinMatcher.new(@mit).length_delta(Licensee::License.find("mit"))
    assert_equal 347.0, Licensee::LevenshteinMatcher.new(@mit).length_delta(isc)
  end

  should "round up potential licenses" do
    assert_equal 6, Licensee::LevenshteinMatcher.new(@mit).potential_licenses.size
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
licensee-5.0.0b7 test/test_licensee_levenshtein_matcher.rb
licensee-5.0.0b6 test/test_licensee_levenshtein_matcher.rb
licensee-5.0.0b5 test/test_licensee_levenshtein_matcher.rb