summaryrefslogtreecommitdiff
path: root/spec/unit
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2024-12-31 11:51:58 -0700
committermo khan <mo@mokhan.ca>2024-12-31 14:40:07 -0700
commit78c6a086164aa83ce2e4e57daadfbdb53a31a37f (patch)
tree2718cbb345bb3c8257ccbaf9e1b8e7913699a3a5 /spec/unit
parent80d59246ec0752128548d6c61a2d44ec498771d7 (diff)
feat: Add support for Ruby 3.2+HEADv0.19.0main
Diffstat (limited to 'spec/unit')
-rw-r--r--spec/unit/cli/build_spec.rb2
-rw-r--r--spec/unit/cli/pull_spec.rb2
-rw-r--r--spec/unit/cli/scan_spec.rb2
-rw-r--r--spec/unit/core/csv_parser_spec.rb2
-rw-r--r--spec/unit/core/dependency_spec.rb6
-rw-r--r--spec/unit/core/http_spec.rb2
-rw-r--r--spec/unit/core/license_plugin_spec.rb4
-rw-r--r--spec/unit/dotnet/index_spec.rb2
-rw-r--r--spec/unit/dotnet/parsers/csproj_spec.rb22
-rw-r--r--spec/unit/dotnet/parsers/sln_spec.rb2
-rw-r--r--spec/unit/js/parsers/npm_spec.rb2
-rw-r--r--spec/unit/js/parsers/yarn_spec.rb2
-rw-r--r--spec/unit/os/parsers/apk_spec.rb2
-rw-r--r--spec/unit/os/parsers/dpkg_spec.rb2
-rw-r--r--spec/unit/php/parsers/composer_spec.rb2
-rw-r--r--spec/unit/python/parsers/pipfile_lock_spec.rb2
-rw-r--r--spec/unit/python/pypi_spec.rb2
-rw-r--r--spec/unit/ruby/parsers/gemfile_lock_spec.rb22
-rw-r--r--spec/unit/spdx/composite_license_spec.rb6
-rw-r--r--spec/unit/spdx/gateway_spec.rb2
-rw-r--r--spec/unit/terraform/parsers/lock_file_spec.rb2
21 files changed, 49 insertions, 43 deletions
diff --git a/spec/unit/cli/build_spec.rb b/spec/unit/cli/build_spec.rb
index f2c6a1f..f7433fa 100644
--- a/spec/unit/cli/build_spec.rb
+++ b/spec/unit/cli/build_spec.rb
@@ -21,7 +21,7 @@ RSpec.describe Spandx::Cli::Commands::Build do
stub_request(:get, 'https://index.rubygems.org/versions')
.to_return(status: 200, body: "created_at: 2020-12-01T00:00:35+00:00\n---\n")
- subject.execute(output: output)
+ subject.execute(output:)
expect(output.string).to eq("nuget\nmaven\npypi\nrubygems\nOK\n")
end
end
diff --git a/spec/unit/cli/pull_spec.rb b/spec/unit/cli/pull_spec.rb
index dbd284a..b648147 100644
--- a/spec/unit/cli/pull_spec.rb
+++ b/spec/unit/cli/pull_spec.rb
@@ -9,7 +9,7 @@ RSpec.describe Spandx::Cli::Commands::Pull do
let(:output) { StringIO.new }
it 'executes `spandx pull` command successfully' do
- subject.execute(output: output)
+ subject.execute(output:)
expect(output.string).to eq(fixture_file('pull.expected').read)
end
diff --git a/spec/unit/cli/scan_spec.rb b/spec/unit/cli/scan_spec.rb
index a11842d..a82e296 100644
--- a/spec/unit/cli/scan_spec.rb
+++ b/spec/unit/cli/scan_spec.rb
@@ -13,7 +13,7 @@ RSpec.describe Spandx::Cli::Commands::Scan do
stub_request(:get, Spandx::Spdx::Gateway::URL)
.to_return(status: 200, body: fixture_file('spdx/json/licenses.json').read)
VCR.use_cassette(lockfile.basename) do
- subject.execute(output: output)
+ subject.execute(output:)
end
end
diff --git a/spec/unit/core/csv_parser_spec.rb b/spec/unit/core/csv_parser_spec.rb
index 8aad98f..b474303 100644
--- a/spec/unit/core/csv_parser_spec.rb
+++ b/spec/unit/core/csv_parser_spec.rb
@@ -2,7 +2,7 @@
RSpec.describe Spandx::Core::CsvParser do
describe '.parse' do
- let(:subject) { described_class.parse(line) }
+ subject { described_class.parse(line) }
context 'when parsing a single line of csv' do
let(:line) { '"spandx","0.0.0","MIT"' + "\n" }
diff --git a/spec/unit/core/dependency_spec.rb b/spec/unit/core/dependency_spec.rb
index 0aebfe3..d8dd1c3 100644
--- a/spec/unit/core/dependency_spec.rb
+++ b/spec/unit/core/dependency_spec.rb
@@ -1,12 +1,12 @@
# frozen_string_literal: true
RSpec.describe Spandx::Core::Dependency do
- subject { described_class.new(name: 'jive', version: '0.1.0', path: path) }
+ subject { described_class.new(name: 'jive', version: '0.1.0', path:) }
let(:path) { Pathname.new('Gemfile.lock') }
def build(name, version, path: 'Gemfile.lock')
- described_class.new(name: name, version: version, path: Pathname.new(path))
+ described_class.new(name:, version:, path: Pathname.new(path))
end
describe '#licenses' do
@@ -31,7 +31,7 @@ RSpec.describe Spandx::Core::Dependency do
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}>") }
+ specify { expect(build('abc', '0.1.0', path:).inspect).to eql("#<#{described_class} name=abc version=0.1.0 path=#{path}>") }
end
describe '#hash' do
diff --git a/spec/unit/core/http_spec.rb b/spec/unit/core/http_spec.rb
index 6aeb084..b0158ce 100644
--- a/spec/unit/core/http_spec.rb
+++ b/spec/unit/core/http_spec.rb
@@ -27,7 +27,7 @@ RSpec.describe ::Spandx::Core::Http do
up_url = "https://#{up_host}/#{SecureRandom.uuid}"
stub_request(:get, up_url).to_return(status: 200)
- expect(subject.get(up_url)).to be_a_kind_of(Net::HTTPSuccess)
+ expect(subject.get(up_url)).to be_a(Net::HTTPSuccess)
end
end
end
diff --git a/spec/unit/core/license_plugin_spec.rb b/spec/unit/core/license_plugin_spec.rb
index 19ed0e6..ef00460 100644
--- a/spec/unit/core/license_plugin_spec.rb
+++ b/spec/unit/core/license_plugin_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe Spandx::Core::LicensePlugin do
- subject { described_class.new(catalogue: catalogue) }
+ subject { described_class.new(catalogue:) }
let(:catalogue) { ::Spandx::Spdx::Catalogue.from_file(fixture_file('spdx/json/licenses.json')) }
@@ -127,7 +127,7 @@ RSpec.describe Spandx::Core::LicensePlugin do
{ package_manager: :yarn, name: 'utils-merge', version: '1.0.1', expected: ['MIT'] },
{ package_manager: :yarn, name: 'vary', version: '1.1.2', expected: ['MIT'] },
].each do |item|
- context "#{item[:package_manager]}-#{item[:name]}-#{item[:version]}" do
+ context "with #{item[:package_manager]}-#{item[:name]}-#{item[:version]}" do
let(:dependency) { ::Spandx::Core::Dependency.new(path: files[item[:package_manager]], name: item[:name], version: item[:version]) }
let(:files) do
{
diff --git a/spec/unit/dotnet/index_spec.rb b/spec/unit/dotnet/index_spec.rb
index 2a873de..50e1ed1 100644
--- a/spec/unit/dotnet/index_spec.rb
+++ b/spec/unit/dotnet/index_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe Spandx::Dotnet::Index do
- subject { described_class.new(directory: directory, gateway: gateway) }
+ subject { described_class.new(directory:, gateway:) }
let(:gateway) { instance_double(Spandx::Dotnet::NugetGateway) }
let(:directory) { Dir.mktmpdir('spandx') }
diff --git a/spec/unit/dotnet/parsers/csproj_spec.rb b/spec/unit/dotnet/parsers/csproj_spec.rb
index 940b6c8..b0cac3b 100644
--- a/spec/unit/dotnet/parsers/csproj_spec.rb
+++ b/spec/unit/dotnet/parsers/csproj_spec.rb
@@ -4,7 +4,7 @@ RSpec.describe Spandx::Dotnet::Parsers::Csproj do
subject(:described_instance) { described_class.new }
def build(name, version, path)
- Spandx::Core::Dependency.new(name: name, version: version, path: path)
+ Spandx::Core::Dependency.new(name:, version:, path:)
end
describe '#parse' do
@@ -15,29 +15,29 @@ RSpec.describe Spandx::Dotnet::Parsers::Csproj do
let(:jive) { subject.find { |item| item.name == 'jive' } }
- specify { expect(subject).to match_array([build('jive', '0.1.0', file)]) }
+ it { is_expected.to match_array([build('jive', '0.1.0', file)]) }
end
context 'when parsing a .csproj file that has a reference to another project' do
subject { described_instance.parse(fixture_file('nuget/nested/test.csproj')) }
- specify { expect(subject.map(&:name)).to match_array(%w[jive xunit]) }
+ it { expect(subject.map(&:name)).to match_array(%w[jive xunit]) }
end
context 'when parsing `Nancy.Hosting.Self.csproj`' do
subject { described_instance.parse(fixture_file('nuget/Nancy.Hosting.Self.csproj')) }
- specify { expect(subject.count).to be(1) }
- specify { expect(subject[0].name).to eql('System.Security.Principal.Windows') }
- specify { expect(subject[0].version).to eql('4.3.0') }
+ it { expect(subject.count).to be(1) }
+ it { expect(subject[0].name).to eql('System.Security.Principal.Windows') }
+ it { expect(subject[0].version).to eql('4.3.0') }
end
end
describe '#match?' do
- specify { is_expected.to be_match(to_path('/root/Packages.props')) }
- specify { is_expected.to be_match(to_path('/root/simple.csproj')) }
- specify { is_expected.not_to be_match(to_path('/root/simple.sln')) }
- specify { is_expected.to be_match(to_path('C:\Documents and Settings\hello world.csproj')) }
- specify { is_expected.to be_match(to_path('C:\Documents and Settings\simple.csproj')) }
+ it { is_expected.to be_match(to_path('/root/Packages.props')) }
+ it { is_expected.to be_match(to_path('/root/simple.csproj')) }
+ it { is_expected.not_to be_match(to_path('/root/simple.sln')) }
+ it { is_expected.to be_match(to_path('C:\Documents and Settings\hello world.csproj')) }
+ it { is_expected.to be_match(to_path('C:\Documents and Settings\simple.csproj')) }
end
end
diff --git a/spec/unit/dotnet/parsers/sln_spec.rb b/spec/unit/dotnet/parsers/sln_spec.rb
index 50b86d7..0effd8a 100644
--- a/spec/unit/dotnet/parsers/sln_spec.rb
+++ b/spec/unit/dotnet/parsers/sln_spec.rb
@@ -2,7 +2,7 @@
RSpec.describe Spandx::Dotnet::Parsers::Sln do
def build(name, version, path)
- Spandx::Core::Dependency.new(name: name, version: version, path: path)
+ Spandx::Core::Dependency.new(name:, version:, path:)
end
describe '#parse' do
diff --git a/spec/unit/js/parsers/npm_spec.rb b/spec/unit/js/parsers/npm_spec.rb
index 37749a5..87484cf 100644
--- a/spec/unit/js/parsers/npm_spec.rb
+++ b/spec/unit/js/parsers/npm_spec.rb
@@ -6,7 +6,7 @@ RSpec.describe Spandx::Js::Parsers::Npm do
let(:expected_dependencies) { fixture_file_content('js/npm/expected').lines.map(&:chomp) }
- specify { expect(subject.map { |x| "#{x.name}@#{x.version}" }) .to match_array(expected_dependencies) }
+ specify { expect(subject.map { |x| "#{x.name}@#{x.version}" }).to match_array(expected_dependencies) }
end
describe '#match?' do
diff --git a/spec/unit/js/parsers/yarn_spec.rb b/spec/unit/js/parsers/yarn_spec.rb
index ba6ceed..f623285 100644
--- a/spec/unit/js/parsers/yarn_spec.rb
+++ b/spec/unit/js/parsers/yarn_spec.rb
@@ -17,7 +17,7 @@ RSpec.describe Spandx::Js::Parsers::Yarn do
let(:expected_dependencies) { fixture_file_content('js/yarn/long_yarn.lock.expected').lines.map(&:chomp) }
let(:result) { subject.parse(fixture_file('js/yarn/long_yarn.lock')) }
- specify { expect(result.map { |x| "#{x.name}@#{x.version}" }) .to match_array(expected_dependencies) }
+ specify { expect(result.map { |x| "#{x.name}@#{x.version}" }).to match_array(expected_dependencies) }
end
describe '#match?' do
diff --git a/spec/unit/os/parsers/apk_spec.rb b/spec/unit/os/parsers/apk_spec.rb
index 0462d1b..220c15f 100644
--- a/spec/unit/os/parsers/apk_spec.rb
+++ b/spec/unit/os/parsers/apk_spec.rb
@@ -7,7 +7,7 @@ RSpec.describe Spandx::Os::Parsers::Apk do
let(:path) { fixture_file('os/lib/apk/db/installed') }
def build(name, version, path)
- Spandx::Core::Dependency.new(name: name, version: version, path: path)
+ Spandx::Core::Dependency.new(name:, version:, path:)
end
specify { expect(subject).to include(build('alpine-baselayout', '3.2.0-r7', path)) }
diff --git a/spec/unit/os/parsers/dpkg_spec.rb b/spec/unit/os/parsers/dpkg_spec.rb
index df63e35..2832fc9 100644
--- a/spec/unit/os/parsers/dpkg_spec.rb
+++ b/spec/unit/os/parsers/dpkg_spec.rb
@@ -7,7 +7,7 @@ RSpec.describe Spandx::Os::Parsers::Dpkg do
let(:path) { fixture_file('os/var/lib/dpkg/status') }
def build(name, version, path)
- Spandx::Core::Dependency.new(name: name, version: version, path: path)
+ Spandx::Core::Dependency.new(name:, version:, path:)
end
specify { expect(subject).to include(build('adduser', '3.118', path)) }
diff --git a/spec/unit/php/parsers/composer_spec.rb b/spec/unit/php/parsers/composer_spec.rb
index a97c1af..aaca74b 100644
--- a/spec/unit/php/parsers/composer_spec.rb
+++ b/spec/unit/php/parsers/composer_spec.rb
@@ -2,7 +2,7 @@
RSpec.describe Spandx::Php::Parsers::Composer do
def build(name, version, path)
- Spandx::Core::Dependency.new(name: name, version: version, path: path)
+ Spandx::Core::Dependency.new(name:, version:, path:)
end
describe '#parse' do
diff --git a/spec/unit/python/parsers/pipfile_lock_spec.rb b/spec/unit/python/parsers/pipfile_lock_spec.rb
index 59fff52..054ff1d 100644
--- a/spec/unit/python/parsers/pipfile_lock_spec.rb
+++ b/spec/unit/python/parsers/pipfile_lock_spec.rb
@@ -7,7 +7,7 @@ RSpec.describe Spandx::Python::Parsers::PipfileLock do
let(:path) { fixture_file('pip/Pipfile.lock') }
def build(name, version, path)
- Spandx::Core::Dependency.new(name: name, version: version, path: path)
+ Spandx::Core::Dependency.new(name:, version:, path:)
end
specify { expect(subject).to match_array([build('six', '1.13.0', path)]) }
diff --git a/spec/unit/python/pypi_spec.rb b/spec/unit/python/pypi_spec.rb
index a0617bd..cb350fb 100644
--- a/spec/unit/python/pypi_spec.rb
+++ b/spec/unit/python/pypi_spec.rb
@@ -141,7 +141,7 @@ RSpec.describe Spandx::Python::Pypi do
let(:source) { 'pypi.org' }
let(:package) { 'six' }
let(:version) { '1.13.0' }
- let(:successful_response_body) { JSON.generate(info: { name: package, version: version }) }
+ let(:successful_response_body) { JSON.generate(info: { name: package, version: }) }
context 'when the default source is reachable' do
before do
diff --git a/spec/unit/ruby/parsers/gemfile_lock_spec.rb b/spec/unit/ruby/parsers/gemfile_lock_spec.rb
index ef81112..81d7076 100644
--- a/spec/unit/ruby/parsers/gemfile_lock_spec.rb
+++ b/spec/unit/ruby/parsers/gemfile_lock_spec.rb
@@ -5,7 +5,7 @@ RSpec.describe Spandx::Ruby::Parsers::GemfileLock do
describe '#parse' do
def build(name, version, path)
- Spandx::Core::Dependency.new(name: name, version: version, path: path)
+ Spandx::Core::Dependency.new(name:, version:, path:)
end
context 'when parsing a Gemfile that was BUNDLED_WITH 1.17.3 with a single dependency' do
@@ -15,7 +15,7 @@ RSpec.describe Spandx::Ruby::Parsers::GemfileLock do
specify { expect(subject[0].meta[:dependencies]).to be_empty }
specify { expect(subject[0].meta[:platform]).to eql('ruby') }
- specify { expect(subject[0].meta[:source]).to be_a_kind_of(Bundler::Source) }
+ specify { expect(subject[0].meta[:source]).to be_a(Bundler::Source) }
specify { expect(subject).to match_array([build('net-hippie', '0.2.7', path)]) }
end
@@ -26,7 +26,7 @@ RSpec.describe Spandx::Ruby::Parsers::GemfileLock do
specify { expect(subject[0].meta[:dependencies]).to be_empty }
specify { expect(subject[0].meta[:platform]).to eql('ruby') }
- specify { expect(subject[0].meta[:source]).to be_a_kind_of(Bundler::Source) }
+ specify { expect(subject[0].meta[:source]).to be_a(Bundler::Source) }
specify { expect(subject).to match_array([build('net-hippie', '0.2.7', path)]) }
end
@@ -37,30 +37,36 @@ RSpec.describe Spandx::Ruby::Parsers::GemfileLock do
let(:spandx) { subject.find { |x| x.name == 'spandx' } }
specify do
- expect(subject.map(&:name)).to match_array([
+ expect(subject.map(&:name).uniq).to match_array([
'addressable',
'ast',
+ 'base64',
+ 'benchmark',
'benchmark-ips',
'benchmark-malloc',
'benchmark-perf',
'benchmark-trend',
+ 'bigdecimal',
'bundler-audit',
'byebug',
'crack',
+ 'csv',
'diff-lcs',
'dotenv',
'faraday',
'faraday-net_http',
'hashdiff',
'hcl2',
+ 'json',
'licensed',
'licensee',
- 'mini_portile2',
- 'multipart-post',
+ 'logger',
'net-hippie',
+ 'net-http',
'nokogiri',
'octokit',
'oj',
+ 'ostruct',
'parallel',
'parser',
'parslet',
@@ -86,7 +92,6 @@ RSpec.describe Spandx::Ruby::Parsers::GemfileLock do
'ruby-prof',
'ruby-progressbar',
'ruby-xxHash',
- 'ruby2_keywords',
'rugged',
'sawyer',
'set',
@@ -98,6 +103,7 @@ RSpec.describe Spandx::Ruby::Parsers::GemfileLock do
'tty-cursor',
'tty-spinner',
'unicode-display_width',
+ 'uri',
'vcr',
'webmock',
'zeitwerk',
@@ -106,7 +112,7 @@ RSpec.describe Spandx::Ruby::Parsers::GemfileLock do
specify { expect(subject.map(&:path).uniq).to match_array([path.expand_path]) }
specify { expect(spandx.meta[:platform]).to eql('ruby') }
- specify { expect(spandx.meta[:source]).to be_a_kind_of(Bundler::Source) }
+ specify { expect(spandx.meta[:source]).to be_a(Bundler::Source) }
end
end
diff --git a/spec/unit/spdx/composite_license_spec.rb b/spec/unit/spdx/composite_license_spec.rb
index 80ee503..d479318 100644
--- a/spec/unit/spdx/composite_license_spec.rb
+++ b/spec/unit/spdx/composite_license_spec.rb
@@ -11,7 +11,7 @@ RSpec.describe Spandx::Spdx::CompositeLicense do
specify { expect(subject.id).to eql('0BSD OR MIT') }
specify { expect(subject.name).to eql("#{catalogue['0BSD'].name} OR #{catalogue['MIT'].name}") }
- specify { expect(subject).to be_kind_of(::Spandx::Spdx::License) }
+ specify { expect(subject).to be_a(::Spandx::Spdx::License) }
end
context 'when parsing an expression with a valid and an invalid license id' do
@@ -19,7 +19,7 @@ RSpec.describe Spandx::Spdx::CompositeLicense do
specify { expect(subject.id).to eql('MIT OR Nonstandard') }
specify { expect(subject.name).to eql("#{catalogue['MIT'].name} OR GPLv3") }
- specify { expect(subject).to be_kind_of(::Spandx::Spdx::License) }
+ specify { expect(subject).to be_a(::Spandx::Spdx::License) }
end
context 'when parsing a license name' do
@@ -40,7 +40,7 @@ RSpec.describe Spandx::Spdx::CompositeLicense do
specify { expect(subject.id).to eql('MIT OR CC0-1.0') }
specify { expect(subject.name).to eql("#{catalogue['MIT'].name} OR #{catalogue['CC0-1.0'].name}") }
- specify { expect(subject).to be_kind_of(::Spandx::Spdx::License) }
+ specify { expect(subject).to be_a(::Spandx::Spdx::License) }
end
end
end
diff --git a/spec/unit/spdx/gateway_spec.rb b/spec/unit/spdx/gateway_spec.rb
index cb78a2a..2623934 100644
--- a/spec/unit/spdx/gateway_spec.rb
+++ b/spec/unit/spdx/gateway_spec.rb
@@ -2,7 +2,7 @@
RSpec.describe Spandx::Spdx::Gateway do
describe '#fetch' do
- subject { described_class.new.fetch(http: http) }
+ subject { described_class.new.fetch(http:) }
let(:url) { described_class::URL }
let(:http) { Spandx::Core::Http.new }
diff --git a/spec/unit/terraform/parsers/lock_file_spec.rb b/spec/unit/terraform/parsers/lock_file_spec.rb
index 56eecd0..bdfc10c 100644
--- a/spec/unit/terraform/parsers/lock_file_spec.rb
+++ b/spec/unit/terraform/parsers/lock_file_spec.rb
@@ -11,7 +11,7 @@ RSpec.describe Spandx::Terraform::Parsers::LockFile do
describe '#parse' do
def build(name, version, path)
- Spandx::Core::Dependency.new(name: name, version: version, path: path)
+ Spandx::Core::Dependency.new(name:, version:, path:)
end
context 'when parsing a .terraform.lock.hcl file' do