Sha256: b00b2cc37c392ea974d4cd3f660cacbb8c61e2a34be693d69f9cdb03fbcffdc7

Contents?: true

Size: 1.12 KB

Versions: 5

Compression:

Stored size: 1.12 KB

Contents

require 'spec_helper'
require 'dummy_finders'

describe CMSScanner::Finders::Findings do

  subject(:findings) { described_class.new }
  let(:dummy)        { CMSScanner::DummyFinding }

  describe '#<<' do
    after { expect(findings).to eq @expected }

    context 'when empty array' do
      it 'adds it' do
        findings << 'empty-test'
        @expected = %w(empty-test)
      end
    end

    context 'when not empty' do
      let(:confirmed) { dummy.new('confirmed') }

      before { findings << dummy.new('test') << confirmed }

      it 'adds a confirmed result correctly' do
        confirmed_dup = confirmed.dup
        confirmed_dup.confidence = 100

        findings << dummy.new('test2')
        findings << confirmed_dup

        confirmed.confirmed_by = confirmed_dup

        @expected = [] << dummy.new('test') << confirmed << dummy.new('test2')
      end
    end
  end

  describe '#+' do
    after { expect(findings).to eq @expected }

    it 'adds it/them' do
      # Dummy assignement to avoid the 'Operator used in void context'
      _ = findings + %w(test1 test2)

      @expected = %w(test1 test2)
    end
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
cms_scanner-0.0.6 spec/lib/finders/findings_spec.rb
cms_scanner-0.0.5 spec/lib/finders/findings_spec.rb
cms_scanner-0.0.4 spec/lib/finders/findings_spec.rb
cms_scanner-0.0.3 spec/lib/finders/findings_spec.rb
cms_scanner-0.0.2 spec/lib/finders/findings_spec.rb