diff options
Diffstat (limited to 'spec/unit/core')
| -rw-r--r-- | spec/unit/core/guess_spec.rb | 3 | ||||
| -rw-r--r-- | spec/unit/core/parser_spec.rb | 21 |
2 files changed, 23 insertions, 1 deletions
diff --git a/spec/unit/core/guess_spec.rb b/spec/unit/core/guess_spec.rb index c001c8a..058b4f6 100644 --- a/spec/unit/core/guess_spec.rb +++ b/spec/unit/core/guess_spec.rb @@ -32,7 +32,7 @@ RSpec.describe Spandx::Core::Guess do end end - pending 'does not contain any duplicate names' do + specify 'does not contain any duplicate names' do items = Hash.new { |hash, key| hash[key] = 0 } active_licenses.each { |license| items[license.name] += 1 } expect(items.find_all { |_x, y| y > 1 }).to be_empty @@ -44,6 +44,7 @@ RSpec.describe Spandx::Core::Guess do specify { expect(subject.license_for(content)&.id).to eql('MIT') } end + specify { expect(subject.license_for(%w[MIT 0BSD]).id).to eql('MIT AND 0BSD') } specify { expect(subject.license_for('(0BSD OR MIT)')&.id).to eql('0BSD OR MIT') } specify { expect(subject.license_for('(BSD-2-Clause OR MIT OR Apache-2.0)')&.id).to eql('BSD-2-Clause OR MIT OR Apache-2.0') } specify { expect(subject.license_for('(BSD-3-Clause OR GPL-2.0)')&.id).to eql('BSD-3-Clause OR GPL-2.0') } diff --git a/spec/unit/core/parser_spec.rb b/spec/unit/core/parser_spec.rb new file mode 100644 index 0000000..9ad5bea --- /dev/null +++ b/spec/unit/core/parser_spec.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +RSpec.describe Spandx::Core::Parser do + subject { described_class } + + describe '.for' do + describe 'when the `composer.lock` file is empty' do + let(:empty_file) { fixture_file('empty/composer.lock') } + let(:result) { subject.for(empty_file) } + + specify { expect(result).to be(Spandx::Core::Parser::UNKNOWN) } + end + + describe 'when the `composer.lock` file is discovered' do + let(:lock_file) { fixture_file('composer/composer.lock') } + let(:result) { subject.for(lock_file) } + + specify { expect(result).to be_instance_of(Spandx::Php::Parsers::Composer) } + end + end +end |
