require 'support/shared_examples_for_issue_checks' RSpec.describe Pluginscan::FileIssuesScanner do before(:all) { @scanner = Pluginscan::FileIssuesScanner.new(Pluginscan::THE_CHECKS) } let(:runner_run_results) { @scanner.scan(file_contents) } describe 'run' do context 'with an empty file' do let(:file_contents) { "" } it "finds no results" do expect(runner_run_results).to eq [] end end describe "matches at the beginning of the line" do # Artificial examples, but older versions of the `function list` helper # would have failed to match these it_behaves_like "matches lines containing", "$_POST", %($_POST[$tagname] : '';) it_behaves_like "matches lines containing", "$wpdb", %($wpdb->prepare( " AND meta_value = %d", $old_id );) it_behaves_like "matches lines containing", "wp_remote_post", %(wp_remote_post( $url, $req_args );) it_behaves_like "matches lines containing", "glob", %(glob( $directory_pattern );) it_behaves_like "matches lines containing", "wp_unslash", %(wp_unslash( $answer );) end end end