Sha256: 453b8d4fdefc0b535e4e362c3b2026e43569ab39601c1ccf004df2aae836d06c

Contents?: true

Size: 1.35 KB

Versions: 1

Compression:

Stored size: 1.35 KB

Contents

require 'spec_helper'

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

    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/Apache.txt
        ])
      end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
license_finder-2.0.0.rc2 spec/lib/license_finder/possible_license_files_spec.rb