Sha256: c1b6c08057120ca4e5f6523b651f2e376b862911d5c0ef97f8470b369ee67a46

Contents?: true

Size: 1.01 KB

Versions: 2

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 6, Licensee::LevenshteinMatcher.new(@mit).potential_licenses.size
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
licensee-4.9.0 test/test_licensee_levenshtein_matcher.rb
licensee-4.8.0 test/test_licensee_levenshtein_matcher.rb