Sha256: 8273f9704cfc8e0a76dde8c6dc6cd3a43b12c99422012e824b9c3f6cd0c1d9bd

Contents?: true

Size: 1.48 KB

Versions: 5

Compression:

Stored size: 1.48 KB

Contents

# frozen_string_literal: true

RSpec.describe 'fixture test' do
  fixtures.each do |fixture|
    let(:options) { { detect_packages: true, detect_readme: true } }

    context "the #{fixture} fixture" do
      subject { Licensee.project(path, **options) }

      let(:path) { fixture_path(fixture) }
      let(:other) { Licensee::License.find('other') }
      let(:none) { Licensee::License.find('none') }
      let(:expectations) { fixture_licenses[fixture] || {} }
      let(:license_file) { subject.license_file }
      let(:matcher) { license_file&.matcher }

      it 'has an expected license in fixtures-licenses.yml' do
        msg = +'Expected an entry in `'
        msg << fixture_path('fixtures-licenses.yml')
        msg << "` for the `#{fixture}` fixture. Please run "
        msg << 'script/dump-fixture-licenses and confirm the output.'
        expect(fixture_licenses).to have_key(fixture), msg
      end

      it 'detects the license' do
        expected = if expectations['key']
                     Licensee::License.find(expectations['key'])
                   else
                     none
                   end

        expect(subject.license).to eql(expected)
      end

      it 'returns the expected hash' do
        hash = license_file&.content_hash
        expect(hash).to eql(expectations['hash'])
      end

      it 'uses the expected matcher' do
        expected = matcher ? matcher.name.to_s : nil
        expect(expected).to eql(expectations['matcher'])
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
licensee-9.18.0 spec/fixture_spec.rb
licensee-9.17.1 spec/fixture_spec.rb
licensee-9.17.0 spec/fixture_spec.rb
licensee-9.16.1 spec/fixture_spec.rb
licensee-9.16.0 spec/fixture_spec.rb