diff options
| author | mo khan <mo.khan@gmail.com> | 2020-05-22 09:28:44 -0600 |
|---|---|---|
| committer | mo khan <mo.khan@gmail.com> | 2020-05-25 18:31:06 -0600 |
| commit | 1ca2a951d05480759af1668ed586793ff5d36a26 (patch) | |
| tree | ca16267ec26b1d8c3b1a1346a1ab9e8689992116 /spec/unit/core/dependency_spec.rb | |
| parent | f8092c7f0ad26d04c8137b3b7d4faea5508a53ce (diff) | |
Convert from using string paths to using Pathname
* Extract a ./bin/run script
* Extract defintion for NEWLINE
* Add specs for matching yarn.lock
* Add specs for Report
* Convert package_manager to pathname
* Display path in report
* matches? to match?
Diffstat (limited to 'spec/unit/core/dependency_spec.rb')
| -rw-r--r-- | spec/unit/core/dependency_spec.rb | 41 |
1 files changed, 27 insertions, 14 deletions
diff --git a/spec/unit/core/dependency_spec.rb b/spec/unit/core/dependency_spec.rb index 648ade2..4fe328a 100644 --- a/spec/unit/core/dependency_spec.rb +++ b/spec/unit/core/dependency_spec.rb @@ -1,30 +1,43 @@ # frozen_string_literal: true RSpec.describe Spandx::Core::Dependency do - subject { described_class.new(package_manager: :nuget, name: 'jive', version: '0.1.0') } + subject { described_class.new(name: 'jive', version: '0.1.0', path: path) } - describe '#licenses' do - specify { expect(subject.licenses).to be_empty } + let(:path) { Pathname.new('Gemfile.lock') } + + def build(name, version, path: 'Gemfile.lock') + described_class.new(name: name, version: version, path: Pathname.new(path)) end - describe '#managed_by?' do - specify { expect(subject).to be_managed_by(:nuget) } - specify { expect(subject).to be_managed_by('nuget') } - specify { expect(subject).not_to be_managed_by('rubygems') } - specify { expect(subject).not_to be_managed_by(nil) } - specify { expect(subject).not_to be_managed_by(:rubygems) } + describe '#licenses' do + specify { expect(subject.licenses).to be_empty } end describe '<=>' do - def build(name, version) - described_class.new(package_manager: :rubygems, name: name, version: version) - end - specify { expect(build('abc', '0.1.0') <=> build('bcd', '0.1.0')).to be < 0 } + specify { expect(build('abc', '0.1.0', path: './CHANGELOG.md') <=> build('bcd', '0.1.0', path: 'Gemfile.lock')).to be < 0 } specify { expect(build('Abc', '0.1.0') <=> build('acd', '0.1.0')).to be < 0 } specify { expect(build('spandx', '1.0.0') <=> build('spandx', '2.0.0')).to be < 0 } - specify { expect(build('spandx', '1.0.0') <=> build('spandx', nil)).to be > 0 } + specify { expect(build('spandx', '1.0.0') <=> build('spandx', nil)).to be < 0 } specify { expect(build('spandx', '1.0.0') <=> build(nil, '1.0.0')).to be > 0 } specify { expect(build('spandx', '1.0.0') <=> nil).to be > 0 } end + + describe '#eql?' do + specify { expect(build('abc', '0.1.0', path: './Gemfile.lock')).to eql(build('abc', '0.1.0', path: './Gemfile.lock')) } + specify { expect(build('abc', '0.1.0', path: './Gemfile.lock')).not_to eql(build('abc', '0.1.0', path: './LICENSE.txt')) } + specify { expect(build('abc', '0.1.0')).not_to eql(build('abc', '0.2.0')) } + specify { expect(build('abc', '0.1.0')).not_to eql(build('xyz', '0.1.0')) } + end + + describe '#inspect' do + specify { expect(build('abc', '0.1.0', path: path).inspect).to eql("#<#{described_class} name=abc version=0.1.0 path=#{path}>") } + end + + describe '#hash' do + specify { expect(build('abc', '0.1.0').hash).to eql(build('abc', '0.1.0').hash) } + specify { expect(build('abc', '0.1.0', path: Pathname.new('Gemfile.lock')).hash).to eql(build('abc', '0.1.0', path: './Gemfile.lock').hash) } + specify { expect(build('abc', '0.1.0').hash).not_to eql(build('abc', '0.0.0').hash) } + specify { expect(build('xyz', '0.1.0').hash).not_to eql(build('abc', '0.1.0').hash) } + end end |
