diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 09:08:42 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 09:08:42 +0000 |
commit | b76ae638462ab0f673e5915986070518dd3f9ad3 (patch) | |
tree | bdab0533383b52873be0ec0eb4d3c66598ff8b91 /spec/support/shared_examples/lib/gitlab/ci/reports | |
parent | 434373eabe7b4be9593d18a585fb763f1e5f1a6f (diff) | |
download | gitlab-ce-b76ae638462ab0f673e5915986070518dd3f9ad3.tar.gz |
Add latest changes from gitlab-org/gitlab@14-2-stable-eev14.2.0-rc42
Diffstat (limited to 'spec/support/shared_examples/lib/gitlab/ci/reports')
-rw-r--r-- | spec/support/shared_examples/lib/gitlab/ci/reports/security/locations/locations_shared_examples.rb | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/spec/support/shared_examples/lib/gitlab/ci/reports/security/locations/locations_shared_examples.rb b/spec/support/shared_examples/lib/gitlab/ci/reports/security/locations/locations_shared_examples.rb new file mode 100644 index 00000000000..3aa04a77e57 --- /dev/null +++ b/spec/support/shared_examples/lib/gitlab/ci/reports/security/locations/locations_shared_examples.rb @@ -0,0 +1,68 @@ +# frozen_string_literal: true + +RSpec.shared_examples 'vulnerability location' do + describe '#initialize' do + subject { described_class.new(**params) } + + context 'when all params are given' do + it 'initializes an instance' do + expect { subject }.not_to raise_error + + expect(subject).to have_attributes(**params) + end + end + + where(:param) do + mandatory_params + end + + with_them do + context "when param #{params[:param]} is missing" do + before do + params.delete(param) + end + + it 'raises an error' do + expect { subject }.to raise_error(ArgumentError) + end + end + end + end + + describe '#fingerprint' do + subject { described_class.new(**params).fingerprint } + + it "generates expected fingerprint" do + expect(subject).to eq(expected_fingerprint) + end + end + + describe '#fingerprint_path' do + subject { described_class.new(**params).fingerprint_path } + + it "generates expected fingerprint" do + expect(subject).to eq(expected_fingerprint_path) + end + end + + describe '#==' do + let(:location_1) { create(:ci_reports_security_locations_sast) } + let(:location_2) { create(:ci_reports_security_locations_sast) } + + subject { location_1 == location_2 } + + it "returns true when fingerprints are equal" do + allow(location_1).to receive(:fingerprint).and_return('fingerprint') + allow(location_2).to receive(:fingerprint).and_return('fingerprint') + + expect(subject).to eq(true) + end + + it "returns false when fingerprints are different" do + allow(location_1).to receive(:fingerprint).and_return('fingerprint') + allow(location_2).to receive(:fingerprint).and_return('another_fingerprint') + + expect(subject).to eq(false) + end + end +end |