Sha256: 13d3b15ebdc1f5c35b1848f40a42e095abb5fb12c24c3ba7465e0743064b1ce1

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

require 'spec_helper'

module LicenseFinder
  describe PossibleLicenseFile do
    context "file parsing" do
      subject { described_class.new('root', 'root/nested/path') }

      context "ignoring text" do
        before do
          allow(subject).to receive(:text).and_return('file text')
        end

        its(:file_path) { should == 'nested/path' }
        its(:text) { should == 'file text' } # this is a terrible test, considering the stubbing
        its(:path) { should == 'root/nested/path' }
      end
    end

    subject { described_class.new('gem', 'gem/license/path') }

    context "with a known license" do
      before do
        allow(subject).to receive(:text).and_return('a known license')

        allow(License).to receive(:find_by_text).with('a known license').and_return(License.find_by_name("MIT"))
      end

      its(:license) { should == License.find_by_name("MIT") }
    end

    context "with an unknown license" do
      before do
        allow(subject).to receive(:text).and_return('')
      end

      its(:license) { should be_nil }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
license_finder-1.2 spec/lib/license_finder/possible_license_file_spec.rb
license_finder-1.2-java spec/lib/license_finder/possible_license_file_spec.rb