mirror of
https://github.com/nvbn/thefuck.git
synced 2025-01-19 12:24:29 +00:00
support rbenv install
This commit is contained in:
parent
1683f45e94
commit
9e0a5dd2bb
25
tests/rules/test_rbenv_install.py
Normal file
25
tests/rules/test_rbenv_install.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import pytest
|
||||||
|
from thefuck.rules.rbenv_install import match, get_new_command
|
||||||
|
from thefuck.types import Command
|
||||||
|
|
||||||
|
expected_new_command = """cd /home/alex/.rbenv/plugins/ruby-build && git pull && cd -"""
|
||||||
|
expected_output = """ruby-build: definition not found: 2.6.1
|
||||||
|
|
||||||
|
See all available versions with `rbenv install --list'.
|
||||||
|
|
||||||
|
If the version you need is missing, try upgrading ruby-build:
|
||||||
|
|
||||||
|
%s""" % expected_new_command
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('script, output', [
|
||||||
|
('rbenv install 2.6.1', expected_output)
|
||||||
|
])
|
||||||
|
def test_match(script, output):
|
||||||
|
assert match(Command(script, output))
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('command, new_command', [
|
||||||
|
(Command('rbenv install 2.6.1', expected_output), expected_new_command)])
|
||||||
|
def test_get_new_command(command, new_command):
|
||||||
|
assert get_new_command(command) == new_command
|
14
thefuck/rules/rbenv_install.py
Normal file
14
thefuck/rules/rbenv_install.py
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
from thefuck.shells import shell
|
||||||
|
from thefuck.utils import for_app
|
||||||
|
|
||||||
|
|
||||||
|
@for_app('rbenv')
|
||||||
|
def match(command):
|
||||||
|
return ('ruby-build: definition not found' in command.output.lower() and
|
||||||
|
'if the version you need is missing, try upgrading ruby-build' in command.output.lower()
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def get_new_command(command):
|
||||||
|
output = command.output.split('\n')[-1].lstrip()
|
||||||
|
return shell.to_shell(output)
|
Loading…
x
Reference in New Issue
Block a user