2017-03-13 22:21:34 +01:00
|
|
|
import pytest
|
|
|
|
from thefuck.rules.missing_space_before_subcommand import (
|
|
|
|
match, get_new_command)
|
2017-08-31 17:58:56 +02:00
|
|
|
from thefuck.types import Command
|
2017-03-13 22:21:34 +01:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
|
|
def all_executables(mocker):
|
|
|
|
return mocker.patch(
|
|
|
|
'thefuck.rules.missing_space_before_subcommand.get_all_executables',
|
|
|
|
return_value=['git', 'ls', 'npm'])
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('script', [
|
|
|
|
'gitbranch', 'ls-la', 'npminstall'])
|
|
|
|
def test_match(script):
|
2017-08-31 17:58:56 +02:00
|
|
|
assert match(Command(script, ''))
|
2017-03-13 22:21:34 +01:00
|
|
|
|
|
|
|
|
2017-04-10 23:23:23 +02:00
|
|
|
@pytest.mark.parametrize('script', ['git branch', 'vimfile'])
|
2017-04-10 23:15:12 +02:00
|
|
|
def test_not_match(script):
|
2017-08-31 17:58:56 +02:00
|
|
|
assert not match(Command(script, ''))
|
2017-03-13 22:21:34 +01:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('script, result', [
|
|
|
|
('gitbranch', 'git branch'),
|
|
|
|
('ls-la', 'ls -la'),
|
|
|
|
('npminstall webpack', 'npm install webpack')])
|
|
|
|
def test_get_new_command(script, result):
|
2017-08-31 17:58:56 +02:00
|
|
|
assert get_new_command(Command(script, '')) == result
|