Sha256: 1b7735ac8699a1b32d32b91118e22548f5a1fb53747bb1c5641b84b40016b895

Contents?: true

Size: 1.32 KB

Versions: 4

Compression:

Stored size: 1.32 KB

Contents

require 'helper'

class TestLicenseeLicenseFile < Minitest::Test

  def setup
    @file = Licensee::LicenseFile.find fixture_path("simple")
    @gpl = Licensee::Licenses.find "GPL-3.0"
    @mit = Licensee::Licenses.find "MIT"
  end

  should "read the file" do
    assert @file.contents =~ /MIT/
  end

  should "known the file length" do
    assert_equal 1077, @file.length
  end

  should "calcualte length deltas" do
    assert_equal 4, @file.length_delta(@mit)
    assert_equal 34065, @file.length_delta(@gpl)
  end

  should "sort licenses by length delta" do
    assert_equal "MIT", @file.licenses_sorted.first.name
    assert_equal "no-license", @file.licenses_sorted.last.name
  end

  should "calculate percent changed" do
    assert @file.percent_changed(@mit) < ".02".to_f
    assert @file.percent_changed(@gpl) > 30
  end

  should "match the license" do
    assert_equal "MIT", @file.match.name
  end

  should "match a txt license" do
    file = Licensee::LicenseFile.find fixture_path("txt")
    assert_equal "MIT", file.match.name
  end

  should "match a md license" do
    file = Licensee::LicenseFile.find fixture_path("md")
    assert_equal "MIT", file.match.name
  end

  should "diff the file" do
    expected = "-Copyright (c) [year] [fullname]\n+Copyright (c) 2014 Ben Balter"
    assert @file.diff.include?(expected)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
licensee-0.1.0 test/test_licensee_license_file.rb
licensee-0.0.3 test/test_licensee_license_file.rb
licensee-0.0.2 test/test_licensee_license_file.rb
licensee-0.0.1 test/test_licensee_license_file.rb