test/functions.rb in licensee-5.0.0 vs test/functions.rb in licensee-6.0.0b1

- old
+ new

@@ -17,12 +17,10 @@ license.sub! "[year]", "2014" license.sub! "[email]", "ben@github.invalid" license end -FakeBlob = Licensee::FilesystemRepository::Blob - def chaos_monkey(string) Random.rand(3).times do string[Random.rand(string.length)] = SecureRandom.base64(Random.rand(3)) end string @@ -33,31 +31,22 @@ text = license_from_path(license) text = chaos_monkey(text) if chaos text = wrap(text, wrap) if wrap - blob = FakeBlob.new(text) - license_file = Licensee::ProjectFile.new(blob, "LICENSE") + license_file = Licensee::Project::LicenseFile.new(text) - actual = license_file.match + actual = license_file.license msg = "No match for #{expected}." - unless actual - Licensee.matchers.each do |matcher| - matcher = matcher.new(license_file) - msg << "#{matcher.class}: #{matcher.confidence}% #{matcher.match.inspect}\n" - end - msg << "Here's the test text:\n#{text}" - end - assert actual, msg assert_equal expected, actual.key, "expeceted #{expected} but got #{actual.key} for .match. Confidence: #{license_file.confidence}. Method: #{license_file.matcher.class}" end def wrap(text, line_width=80) text = text.clone - copyright = /^#{Licensee::CopyrightMatcher::REGEX}$/i.match(text) - text.gsub! /^#{Licensee::CopyrightMatcher::REGEX}$/i, '[COPYRIGHT]' if copyright + copyright = /^#{Licensee::Matchers::Copyright::REGEX}$/i.match(text) + text.gsub! /^#{Licensee::Matchers::Copyright::REGEX}$/i, '[COPYRIGHT]' if copyright text.gsub! /([^\n])\n([^\n])/, '\1 \2' text = text.split("\n").collect do |line| line.length > line_width ? line.gsub(/(.{1,#{line_width}})(\s+|$)/, "\\1\n").strip : line end * "\n" text.gsub! "[COPYRIGHT]", "\n#{copyright}\n" if copyright