2015-04-25 03:13:57 +02:00
|
|
|
|
# -*- encoding: utf-8 -*-
|
|
|
|
|
|
2015-04-23 08:35:50 +02:00
|
|
|
|
from thefuck.rules.fix_alt_space import match, get_new_command
|
2015-04-25 02:35:26 +02:00
|
|
|
|
from tests.utils import Command
|
2015-04-23 08:35:50 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_match():
|
2015-04-25 02:35:26 +02:00
|
|
|
|
"""The character before 'grep' is Alt+Space, which happens frequently
|
|
|
|
|
on the Mac when typing the pipe character (Alt+7), and holding the Alt
|
|
|
|
|
key pressed for longer than necessary.
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
assert match(Command(u'ps -ef | grep foo',
|
|
|
|
|
stderr=u'-bash: grep: command not found'), None)
|
|
|
|
|
assert not match(Command('ps -ef | grep foo'), None)
|
|
|
|
|
assert not match(Command(), None)
|
2015-04-23 08:35:50 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_get_new_command():
|
|
|
|
|
""" Replace the Alt+Space character by a simple space """
|
2015-04-25 02:35:26 +02:00
|
|
|
|
assert get_new_command(Command(u'ps -ef | grep foo'), None)\
|
|
|
|
|
== 'ps -ef | grep foo'
|