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