2015-07-24 00:47:57 +03:00
|
|
|
import pytest
|
2016-01-31 18:45:43 -02:00
|
|
|
from io import BytesIO
|
2017-08-31 17:58:56 +02:00
|
|
|
from thefuck.types import Command
|
2015-07-24 00:47:57 +03:00
|
|
|
from thefuck.rules.gulp_not_task import match, get_new_command
|
|
|
|
|
|
|
|
|
2017-08-31 17:58:56 +02:00
|
|
|
def output(task):
|
2015-07-24 00:47:57 +03:00
|
|
|
return '''[00:41:11] Using gulpfile gulpfile.js
|
|
|
|
[00:41:11] Task '{}' is not in your gulpfile
|
|
|
|
[00:41:11] Please check the documentation for proper gulpfile formatting
|
|
|
|
'''.format(task)
|
|
|
|
|
|
|
|
|
|
|
|
def test_match():
|
2017-08-31 17:58:56 +02:00
|
|
|
assert match(Command('gulp srve', output('srve')))
|
2015-07-24 00:47:57 +03:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('script, stdout', [
|
|
|
|
('gulp serve', ''),
|
2017-08-31 17:58:56 +02:00
|
|
|
('cat srve', output('srve'))])
|
2015-07-24 00:47:57 +03:00
|
|
|
def test_not_march(script, stdout):
|
2015-09-07 13:00:29 +03:00
|
|
|
assert not match(Command(script, stdout))
|
2015-07-24 00:47:57 +03:00
|
|
|
|
|
|
|
|
|
|
|
def test_get_new_command(mocker):
|
2016-01-31 18:45:43 -02:00
|
|
|
mock = mocker.patch('subprocess.Popen')
|
|
|
|
mock.return_value.stdout = BytesIO(b'serve \nbuild \ndefault \n')
|
2017-08-31 17:58:56 +02:00
|
|
|
command = Command('gulp srve', output('srve'))
|
2015-09-07 13:00:29 +03:00
|
|
|
assert get_new_command(command) == ['gulp serve', 'gulp default']
|