Sha256: 9996955e2837bcdb485397ef087a4e9c4e391aca2cfaeec97b1a906be05a9329

Contents?: true

Size: 1.47 KB

Versions: 9

Compression:

Stored size: 1.47 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_path).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(&:file_path).should =~ %w[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(&:file_path).should =~ %w[
          LICENSE/BSD-2-Clause.txt
          LICENSE/GPL-2.0.txt
          LICENSE/MIT.txt
          LICENSE/RUBY.txt
          COPYING
          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

9 entries across 9 versions & 1 rubygems

Version Path
license_finder-1.1.1-java spec/lib/license_finder/possible_license_files_spec.rb
license_finder-1.1.1 spec/lib/license_finder/possible_license_files_spec.rb
license_finder-1.1.0 spec/lib/license_finder/possible_license_files_spec.rb
license_finder-1.0.1 spec/lib/license_finder/possible_license_files_spec.rb
license_finder-1.0.0.1 spec/lib/license_finder/possible_license_files_spec.rb
license_finder-1.0.0.0 spec/lib/license_finder/possible_license_files_spec.rb
license_finder-1.0.0.0-java spec/lib/license_finder/possible_license_files_spec.rb
license_finder-0.9.5.1-java spec/lib/license_finder/possible_license_files_spec.rb
license_finder-0.9.5.1 spec/lib/license_finder/possible_license_files_spec.rb