Testing Gulp Task Name Correction Implementation in TheFuck
This test suite validates the functionality of the ‘gulp_not_task’ rule in TheFuck, which handles mistyped Gulp task names. It verifies error detection and command correction for invalid Gulp tasks, ensuring the tool provides accurate suggestions for misspelled commands.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
nvbn/thefuck
tests/rules/test_gulp_not_task.py
import pytest
from io import BytesIO
from thefuck.types import Command
from thefuck.rules.gulp_not_task import match, get_new_command
def output(task):
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():
assert match(Command('gulp srve', output('srve')))
@pytest.mark.parametrize('script, stdout', [
('gulp serve', ''),
('cat srve', output('srve'))])
def test_not_march(script, stdout):
assert not match(Command(script, stdout))
def test_get_new_command(mocker):
mock = mocker.patch('subprocess.Popen')
mock.return_value.stdout = BytesIO(b'serve
build
default
')
command = Command('gulp srve', output('srve'))
assert get_new_command(command) == ['gulp serve', 'gulp default']