1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-10-30 14:44:05 +00:00

Suggest ag -Q when relevant

This detects when `ag` suggests the `-Q` option, and adds it.
This commit is contained in:
Joseph Frazier
2016-10-03 00:30:48 -04:00
parent db7dffdb44
commit db4b37910d
3 changed files with 37 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
import pytest
from thefuck.rules.ag_literal import match, get_new_command
from tests.utils import Command
stderr = ('ERR: Bad regex! pcre_compile() failed at position 1: missing )\n'
'If you meant to search for a literal string, run ag with -Q\n')
matching_command = Command(script='ag \\(', stderr=stderr)
@pytest.mark.parametrize('command', [
matching_command])
def test_match(command):
assert match(matching_command)
@pytest.mark.parametrize('command', [
Command(script='ag foo', stderr='')])
def test_not_match(command):
assert not match(command)
@pytest.mark.parametrize('command, new_command', [
(matching_command, 'ag -Q \\(')])
def test_get_new_command(command, new_command):
assert get_new_command(command) == new_command