Sha256: 727233ab3cec833b4be5a2aa573a318f3b3aaaf5c15a12ad4eee4c07d599f9c6

Contents?: true

Size: 1.2 KB

Versions: 1

Compression:

Stored size: 1.2 KB

Contents

require 'acceptance_spec_helper'

RSpec.describe Pluginscan::Scanner do
  before do
    # these are slow, so don't run them if we don't have to
    stub_sloccount
    stub_cloc
    stub_vuln_check
  end

  describe '.scan' do
    let(:output) { StringIO.new }

    describe "Sloccount Report", type: [:file, :process] do
      subject(:scanner) { Pluginscan::Scanner.new(cloc: false, output: output) }

      it "displays a message when sloccount was unavailable (doesn't error out)" do
        system_sloccount = fake_system_sloccount
        allow(system_sloccount).to receive(:available?).and_return false
        stub_sloccount(system_sloccount)

        setup_tempdir 'tmp'
        scanner.scan 'tmp'
        expect(output.string).to match(/The 'sloccount' command is unavailable/)
      end

      it "displays a message when sloccount threw an error (doesn't error out)" do
        system_sloccount = fake_system_sloccount
        allow(system_sloccount).to receive(:call)
          .and_raise SLOCCountScanner::Exception, "Some nonsense"
        stub_sloccount(system_sloccount)

        setup_tempdir 'tmp'
        scanner.scan 'tmp'
        expect(output.string).to match(/Some nonsense/)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pluginscan-0.9.0 spec/acceptance/sloccount_spec.rb