summaryrefslogtreecommitdiff
path: root/spec/models/concerns/vulnerability_finding_signature_helpers_spec.rb
blob: 0a71699971e7971d35111b51586f70efe46f4256 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe VulnerabilityFindingSignatureHelpers do
  let(:cls) do
    Class.new do
      include VulnerabilityFindingSignatureHelpers
      attr_accessor :algorithm_type

      def initialize(algorithm_type)
        @algorithm_type = algorithm_type
      end
    end
  end

  describe '#priority' do
    it 'returns numeric values of the priority string' do
      expect(cls.new('scope_offset').priority).to eq(3)
      expect(cls.new('location').priority).to eq(2)
      expect(cls.new('hash').priority).to eq(1)
    end
  end

  describe '#self.priority' do
    it 'returns the numeric value of the provided string' do
      expect(cls.priority('scope_offset')).to eq(3)
      expect(cls.priority('location')).to eq(2)
      expect(cls.priority('hash')).to eq(1)
    end
  end
end