Sha256: 126d0851d7779d6bf7c44116f23f4a11eb9b804d745f025ef957db7b190595ff

Contents?: true

Size: 1.18 KB

Versions: 1

Compression:

Stored size: 1.18 KB

Contents

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

Version data entries

1 entries across 1 versions & 1 rubygems

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