Sha256: 876105a8fe870f2e1eaf85544e3fd533f90c208521c5e5789758ddabc805e41a

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

require 'spec_helper'

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

    context "ignoring text" do
      before do
        stub(IO).read { "file text" }
        stub(IO).binread { "file text" }
      end

      its(:file_path) { should == 'nested/path' }
      its(:file_name) { should == 'path' }
      its(:text) { should == 'file text' }
    end
  end

  subject { LicenseFinder::PossibleLicenseFile.new('gem', 'gem/license/path') }

  context "with a known license" do
    before do
      stub(IO).read { "a known license" }
      stub(IO).binread { "a known license" }

      stub(LicenseFinder::License::MIT).new("a known license").stub!.matches? { true }
    end

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

  context "with an unknown license" do
    before do
      stub(IO).read { "" }
      stub(IO).binread { "" }

      any_instance_of(LicenseFinder::License::Base, :matches? => false)
    end

    its(:license) { should be_nil }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
license_finder-0.6.0 spec/lib/license_finder/possible_license_file_spec.rb
license_finder-0.5.0 spec/lib/license_finder/possible_license_file_spec.rb