require 'acceptance_spec_helper' RSpec.describe Pluginscan::Scanner do before do stub_vuln_check end let(:output) { StringIO.new } # Place to redirect normal output to describe ".scan", "creating vim output file", type: :file do it 'creates an output file when passed error_list_file as a parameter' do setup_tempdir 'tmp' file_name = add_php_file 'tmp', " eval('delete all the things')\n global $wpdb;" output_file = StringIO.new # Stand in for a real file Pluginscan::Scanner.new(cloc: false, sloccount: false, output: output, error_list_file: output_file).scan('tmp') expect(output_file.string) .to include(%("#{file_name}", line 2, col 10: [Database access][IGNORE] global $wpdb;)) .and include(%("#{file_name}", line 1, col 2: [PHP code generation] eval('delete all the things'))) end it 'raises an error if passed a non-IO object as output' do expect{ Pluginscan::Scanner.new(cloc: false, sloccount: false, output: output, error_list_file: 1).scan "tmp" } .to raise_error(Pluginscan::IOError, "Expected error_list_file to be an I/O object (e.g. a file) which implements `puts`. Got a Fixnum") end end end