Sha256: cba785fa7303133190de50e965bf0ed5856c29948c50f9ded714774211abf9d2

Contents?: true

Size: 1.23 KB

Versions: 21

Compression:

Stored size: 1.23 KB

Contents

require 'spec_helper'

module LicenseFinder
  describe LicenseFiles do
    describe "#find" do
      def files_in(fixture)
        root_path = fixture_path(fixture)
        subject = described_class.find(root_path.to_s)

        subject.map do |f|
          Pathname(f.path).relative_path_from(root_path).to_s
        end
      end

      it "is empty if passed a nil install path" do
        subject = described_class.new nil
        expect(subject.find).to eq([])
      end

      it "is empty if there aren't any license files" do
        expect(files_in('not/a/dir')).to eq([])
      end

      it "includes files with names like LICENSE, README or COPYING" do
        expect(files_in('license_names')).to match_array(
        %w[COPYING.txt LICENSE Mit-License README.rdoc Licence.rdoc]
        )
      end

      it "includes files deep in the hierarchy" do
        expect(files_in('nested_gem')).to eq(['vendor/LICENSE'])
      end

      it "includes files nested inside LICENSE directory" do
        expect(files_in('license_directory')).to match_array(%w[
          COPYING
          LICENSE/MIT.txt
        ])
      end

      it "handles non UTF8 encodings" do
        expect { files_in('utf8_gem') }.not_to raise_error
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
license_finder-3.0.4 spec/lib/license_finder/packages/license_files_spec.rb
license_finder-3.0.2 spec/lib/license_finder/packages/license_files_spec.rb
license_finder-3.0.1 spec/lib/license_finder/packages/license_files_spec.rb
license_finder-3.0.0 spec/lib/license_finder/packages/license_files_spec.rb
license_finder-2.1.2 spec/lib/license_finder/packages/license_files_spec.rb
license_finder-2.1.1 spec/lib/license_finder/packages/license_files_spec.rb
license_finder-2.1.0 spec/lib/license_finder/packages/license_files_spec.rb
license_finder-2.1.0.rc9 spec/lib/license_finder/packages/license_files_spec.rb
license_finder-2.1.0.rc8 spec/lib/license_finder/packages/license_files_spec.rb
license_finder-2.1.0.rc7 spec/lib/license_finder/packages/license_files_spec.rb
license_finder-2.1.0.rc6 spec/lib/license_finder/packages/license_files_spec.rb
license_finder-2.1.0.rc5 spec/lib/license_finder/packages/license_files_spec.rb
license_finder-2.1.0.rc4 spec/lib/license_finder/packages/license_files_spec.rb
license_finder-2.1.0.rc3 spec/lib/license_finder/packages/license_files_spec.rb
license_finder-2.1.0.rc2 spec/lib/license_finder/packages/license_files_spec.rb
license_finder-2.1.0.rc1 spec/lib/license_finder/packages/license_files_spec.rb
license_finder-2.0.4 spec/lib/license_finder/packages/license_files_spec.rb
license_finder-2.0.3 spec/lib/license_finder/packages/license_files_spec.rb
license_finder-2.0.2 spec/lib/license_finder/packages/license_files_spec.rb
license_finder-2.0.1 spec/lib/license_finder/packages/license_files_spec.rb