Sha256: db44d70f88e6cae4897abad74a9d1b591a072f3bb98207bead35185293b73279

Contents?: true

Size: 1.63 KB

Versions: 14

Compression:

Stored size: 1.63 KB

Contents

require 'spec_helper'

module LicenseFinder
  describe PossibleLicenseFiles do
    def fixture_path(fixture)
      Pathname.new(File.join(File.dirname(__FILE__), '..', '..', '..', 'spec', 'fixtures', fixture)).realpath.to_s
    end

    describe "#find" do
      it "is empty if there aren't any license files" do
        subject = described_class.new('/not/a/dir')
        subject.find.should == []
      end

      it "includes files with names like LICENSE, License or COPYING" do
        subject = described_class.new(fixture_path('license_names'))

        subject.find.map(&:file_name).should =~
        %w[COPYING.txt LICENSE Mit-License README.rdoc Licence.rdoc]
      end

      it "includes files deep in the hierarchy" do
        subject = described_class.new(fixture_path('nested_gem'))

        subject.find.map { |f| [f.file_name, f.file_path] }.should =~ [
          %w[LICENSE vendor/LICENSE]
        ]
      end

      it "includes both files nested inside LICENSE directory and top level files" do
        subject = described_class.new(fixture_path('license_directory'))
        found_license_files = subject.find

        found_license_files.map { |f| [f.file_name, f.file_path] }.should =~ [
          %w[BSD-2-Clause.txt LICENSE/BSD-2-Clause.txt],
          %w[GPL-2.0.txt LICENSE/GPL-2.0.txt],
          %w[MIT.txt LICENSE/MIT.txt],
          %w[RUBY.txt LICENSE/RUBY.txt],
          %w[COPYING COPYING],
          %w[LICENSE LICENSE/LICENSE]
        ]
      end

      it "handles non UTF8 encodings" do
        subject = described_class.new(fixture_path('utf8_gem'))
        expect { subject.find }.not_to raise_error
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
license_finder-0.9.5 spec/lib/license_finder/possible_license_files_spec.rb
license_finder-0.9.5-java spec/lib/license_finder/possible_license_files_spec.rb
license_finder-0.9.4-java spec/lib/license_finder/possible_license_files_spec.rb
license_finder-0.9.4 spec/lib/license_finder/possible_license_files_spec.rb
license_finder-0.9.3-java spec/lib/license_finder/possible_license_files_spec.rb
license_finder-0.9.3 spec/lib/license_finder/possible_license_files_spec.rb
license_finder-0.9.2-java spec/lib/license_finder/possible_license_files_spec.rb
license_finder-0.9.2 spec/lib/license_finder/possible_license_files_spec.rb
license_finder-0.9.1-java spec/lib/license_finder/possible_license_files_spec.rb
license_finder-0.9.1 spec/lib/license_finder/possible_license_files_spec.rb
license_finder-0.9.0-java spec/lib/license_finder/possible_license_files_spec.rb
license_finder-0.9.0 spec/lib/license_finder/possible_license_files_spec.rb
license_finder-0.8.2-java spec/lib/license_finder/possible_license_files_spec.rb
license_finder-0.8.2 spec/lib/license_finder/possible_license_files_spec.rb