mirror of https://github.com/licensee/licensee.git
test
This commit is contained in:
parent
b94497a16b
commit
8e5abe96e5
|
@ -7,7 +7,7 @@ class Licensee
|
|||
content = content.gsub(/[[:space:]]+\z/, '')
|
||||
content = content.gsub(/^#{CopyrightMatcher::REGEX}$/i, '')
|
||||
content = content.gsub(/[[:space:]]+/, ' ')
|
||||
content.squeeze(' ')
|
||||
content.squeeze(' ').strip
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
require 'helper'
|
||||
|
||||
class TestHelper
|
||||
include Licensee::ContentHelper
|
||||
end
|
||||
|
||||
class TestLicenseeContentHelper < Minitest::Test
|
||||
|
||||
def setup
|
||||
@helper = TestHelper.new
|
||||
end
|
||||
|
||||
def normalize(content)
|
||||
@helper.normalize_content(content)
|
||||
end
|
||||
|
||||
should "downcase content" do
|
||||
assert_equal "foo", normalize("Foo")
|
||||
end
|
||||
|
||||
should "strip leading whitespace" do
|
||||
assert_equal "foo", normalize("\n Foo")
|
||||
end
|
||||
|
||||
should "strip trailing whitespace" do
|
||||
assert_equal "foo", normalize("Foo \n ")
|
||||
end
|
||||
|
||||
should "strip double spaces" do
|
||||
assert_equal "foo bar", normalize("Foo bar")
|
||||
end
|
||||
|
||||
should "strip copyrights" do
|
||||
assert_equal "foo", normalize("Copyright (c) 2015 Ben Balter\nFoo")
|
||||
end
|
||||
end
|
|
@ -24,7 +24,7 @@ class TestLicenseeLevenshteinMatcher < Minitest::Test
|
|||
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 346.0, Licensee::LevenshteinMatcher.new(@mit).length_delta(isc)
|
||||
assert_equal 347.0, Licensee::LevenshteinMatcher.new(@mit).length_delta(isc)
|
||||
end
|
||||
|
||||
should "round up potential licenses" do
|
||||
|
|
|
@ -21,11 +21,15 @@ class TestLicenseeProjectFile < Minitest::Test
|
|||
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 = {
|
||||
|
|
Loading…
Reference in New Issue