Sha256: 407b8ac773d12a22882a5d67ece0ada260f37a8c770e4ed1e7e3a97360dbe307

Contents?: true

Size: 1.01 KB

Versions: 24

Compression:

Stored size: 1.01 KB

Contents

require 'helper'

class TestLicenseeLevenshteinMatcher < Minitest::Test

  def setup
    text = license_from_path( Licensee::Licenses.find("mit").path )
    blob = FakeBlob.new(text)
    @mit = Licensee::LicenseFile.new(blob)
  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 964.8000000000001, Licensee::LevenshteinMatcher.new(@mit).max_delta
  end

  should "calculate length delta" do
    isc = Licensee::Licenses.find("isc")
    assert_equal 2, Licensee::LevenshteinMatcher.new(@mit).length_delta(Licensee::Licenses.find("mit"))
    assert_equal 334, Licensee::LevenshteinMatcher.new(@mit).length_delta(isc)
  end

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

end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
licensee-4.7.4 test/test_licensee_levenshtein_matcher.rb
licensee-4.7.3 test/test_licensee_levenshtein_matcher.rb
licensee-4.7.2 test/test_licensee_levenshtein_matcher.rb
licensee-4.7.1 test/test_licensee_levenshtein_matcher.rb
licensee-4.7.0 test/test_licensee_levenshtein_matcher.rb
licensee-4.6.0 test/test_licensee_levenshtein_matcher.rb
licensee-4.5.0 test/test_licensee_levenshtein_matcher.rb
licensee-4.4.2 test/test_licensee_levenshtein_matcher.rb
licensee-4.4.1 test/test_licensee_levenshtein_matcher.rb
licensee-4.4.0 test/test_licensee_levenshtein_matcher.rb
licensee-4.3.3 test/test_licensee_levenshtein_matcher.rb
licensee-4.3.2 test/test_licensee_levenshtein_matcher.rb
licensee-4.3.1 test/test_licensee_levenshtein_matcher.rb
licensee-4.3.0 test/test_licensee_levenshtein_matcher.rb
licensee-4.2.4 test/test_licensee_levenshtein_matcher.rb
licensee-4.2.3 test/test_licensee_levenshtein_matcher.rb
licensee-4.2.2 test/test_licensee_levenshtein_matcher.rb
licensee-4.2.1 test/test_licensee_levenshtein_matcher.rb
licensee-4.2.0 test/test_licensee_levenshtein_matcher.rb
licensee-4.1.2 test/test_licensee_levenshtein_matcher.rb