diff options
Diffstat (limited to 'spec/lib/gitlab/ci/reports/sbom')
-rw-r--r-- | spec/lib/gitlab/ci/reports/sbom/component_spec.rb | 16 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/reports/sbom/report_spec.rb | 26 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/reports/sbom/reports_spec.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/reports/sbom/source_spec.rb | 16 |
4 files changed, 21 insertions, 39 deletions
diff --git a/spec/lib/gitlab/ci/reports/sbom/component_spec.rb b/spec/lib/gitlab/ci/reports/sbom/component_spec.rb index 672117c311f..06ea3433ef0 100644 --- a/spec/lib/gitlab/ci/reports/sbom/component_spec.rb +++ b/spec/lib/gitlab/ci/reports/sbom/component_spec.rb @@ -1,23 +1,23 @@ # frozen_string_literal: true -require 'spec_helper' +require 'fast_spec_helper' RSpec.describe Gitlab::Ci::Reports::Sbom::Component do let(:attributes) do { - 'type' => 'library', - 'name' => 'component-name', - 'version' => 'v0.0.1' + type: 'library', + name: 'component-name', + version: 'v0.0.1' } end - subject { described_class.new(attributes) } + subject { described_class.new(**attributes) } it 'has correct attributes' do expect(subject).to have_attributes( - component_type: 'library', - name: 'component-name', - version: 'v0.0.1' + component_type: attributes[:type], + name: attributes[:name], + version: attributes[:version] ) end end diff --git a/spec/lib/gitlab/ci/reports/sbom/report_spec.rb b/spec/lib/gitlab/ci/reports/sbom/report_spec.rb index d7a285ab13c..6ffa93e5fc8 100644 --- a/spec/lib/gitlab/ci/reports/sbom/report_spec.rb +++ b/spec/lib/gitlab/ci/reports/sbom/report_spec.rb @@ -15,40 +15,22 @@ RSpec.describe Gitlab::Ci::Reports::Sbom::Report do end describe '#set_source' do - let_it_be(:source) do - { - 'type' => :dependency_scanning, - 'data' => { - 'input_file' => { 'path' => 'package-lock.json' }, - 'source_file' => { 'path' => 'package.json' }, - 'package_manager' => { 'name' => 'npm' }, - 'language' => { 'name' => 'JavaScript' } - }, - 'fingerprint' => 'c01df1dc736c1148717e053edbde56cb3a55d3e31f87cea955945b6f67c17d42' - } - end + let_it_be(:source) { create(:ci_reports_sbom_source) } it 'stores the source' do report.set_source(source) - expect(report.source).to be_a(Gitlab::Ci::Reports::Sbom::Source) + expect(report.source).to eq(source) end end describe '#add_component' do - let_it_be(:components) do - [ - { 'type' => 'library', 'name' => 'component1', 'version' => 'v0.0.1' }, - { 'type' => 'library', 'name' => 'component2', 'version' => 'v0.0.2' }, - { 'type' => 'library', 'name' => 'component2' } - ] - end + let_it_be(:components) { create_list(:ci_reports_sbom_component, 3) } it 'appends components to a list' do components.each { |component| report.add_component(component) } - expect(report.components.size).to eq(3) - expect(report.components).to all(be_a(Gitlab::Ci::Reports::Sbom::Component)) + expect(report.components).to match_array(components) end end end diff --git a/spec/lib/gitlab/ci/reports/sbom/reports_spec.rb b/spec/lib/gitlab/ci/reports/sbom/reports_spec.rb index 97d8d7abb33..75ea91251eb 100644 --- a/spec/lib/gitlab/ci/reports/sbom/reports_spec.rb +++ b/spec/lib/gitlab/ci/reports/sbom/reports_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'spec_helper' +require 'fast_spec_helper' RSpec.describe Gitlab::Ci::Reports::Sbom::Reports do subject(:reports_list) { described_class.new } diff --git a/spec/lib/gitlab/ci/reports/sbom/source_spec.rb b/spec/lib/gitlab/ci/reports/sbom/source_spec.rb index 2d6434534a0..cb30bd721dd 100644 --- a/spec/lib/gitlab/ci/reports/sbom/source_spec.rb +++ b/spec/lib/gitlab/ci/reports/sbom/source_spec.rb @@ -1,29 +1,29 @@ # frozen_string_literal: true -require 'spec_helper' +require 'fast_spec_helper' RSpec.describe Gitlab::Ci::Reports::Sbom::Source do let(:attributes) do { - 'type' => :dependency_scanning, - 'data' => { + type: :dependency_scanning, + data: { 'category' => 'development', 'input_file' => { 'path' => 'package-lock.json' }, 'source_file' => { 'path' => 'package.json' }, 'package_manager' => { 'name' => 'npm' }, 'language' => { 'name' => 'JavaScript' } }, - 'fingerprint' => '4dbcb747e6f0fb3ed4f48d96b777f1d64acdf43e459fdfefad404e55c004a188' + fingerprint: '4dbcb747e6f0fb3ed4f48d96b777f1d64acdf43e459fdfefad404e55c004a188' } end - subject { described_class.new(attributes) } + subject { described_class.new(**attributes) } it 'has correct attributes' do expect(subject).to have_attributes( - source_type: attributes['type'], - data: attributes['data'], - fingerprint: attributes['fingerprint'] + source_type: attributes[:type], + data: attributes[:data], + fingerprint: attributes[:fingerprint] ) end end |