Sha256: 8b72468195dfcab127d5f471e7694099677edde4a2687ec9f71dbc1e32adcd09

Contents?: true

Size: 1.27 KB

Versions: 12

Compression:

Stored size: 1.27 KB

Contents

RSpec.describe Licensee::ProjectFiles::ProjectFile do
  let(:filename) { 'LICENSE.txt' }
  let(:mit) { Licensee::License.find('mit') }
  let(:content) { mit.content }
  let(:possible_matchers) { [Licensee::Matchers::Exact] }

  subject { described_class.new(content, filename) }
  before do
    allow(subject).to receive(:possible_matchers).and_return(possible_matchers)
  end
  before { allow(subject).to receive(:length).and_return(mit.length) }
  before { allow(subject).to receive(:wordset).and_return(mit.wordset) }

  it 'stores the content' do
    expect(subject.content).to eql(content)
  end

  it 'stores the filename' do
    expect(subject.filename).to eql(filename)
  end

  it 'returns the matcher' do
    expect(subject.matcher).to be_a(Licensee::Matchers::Exact)
  end

  it 'returns the confidence' do
    expect(subject.confidence).to eql(100)
  end

  it 'returns the license' do
    expect(subject.license).to eql(mit)
  end

  context 'with additional metadata' do
    subject { described_class.new(content, name: filename, dir: Dir.pwd) }

    it 'stores the filename' do
      expect(subject.filename).to eql(filename)
      expect(subject[:name]).to eql(filename)
    end

    it 'stores additional metadata' do
      expect(subject[:dir]).to eql(Dir.pwd)
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
licensee-9.8.0 spec/licensee/project_files/project_file_spec.rb
licensee-9.7.0 spec/licensee/project_files/project_file_spec.rb
licensee-9.6.0 spec/licensee/project_files/project_file_spec.rb
licensee-9.5.0 spec/licensee/project_files/project_file_spec.rb
licensee-9.4.0 spec/licensee/project_files/project_file_spec.rb
licensee-9.3.1 spec/licensee/project_files/project_file_spec.rb
licensee-9.3.0 spec/licensee/project_files/project_file_spec.rb
licensee-9.2.1 spec/licensee/project_files/project_file_spec.rb
licensee-9.2.0 spec/licensee/project_files/project_file_spec.rb
licensee-9.1.0 spec/licensee/project_files/project_file_spec.rb
licensee-9.0.0 spec/licensee/project_files/project_file_spec.rb
licensee-9.0.0.beta.1 spec/licensee/project_files/project_file_spec.rb