diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2020-07-03 19:27:38 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2020-07-03 19:27:38 +0000 |
commit | a1fd3d0746ade4480fa73bf03b03b268b4c2fc6c (patch) | |
tree | 7e819595d15c58bd917c69fdaf2b6f530482d9f9 /tests/languages | |
parent | Adding upstream version 2.5.1. (diff) | |
download | pre-commit-a1fd3d0746ade4480fa73bf03b03b268b4c2fc6c.tar.xz pre-commit-a1fd3d0746ade4480fa73bf03b03b268b4c2fc6c.zip |
Adding upstream version 2.6.0.upstream/2.6.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/languages')
-rw-r--r-- | tests/languages/ruby_test.py | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/tests/languages/ruby_test.py b/tests/languages/ruby_test.py index 36a029d..853bb73 100644 --- a/tests/languages/ruby_test.py +++ b/tests/languages/ruby_test.py @@ -1,15 +1,39 @@ import os.path +from unittest import mock +import pytest + +import pre_commit.constants as C +from pre_commit import parse_shebang from pre_commit.languages import ruby from pre_commit.prefix import Prefix from pre_commit.util import cmd_output -from testing.util import xfailif_windows_no_ruby +from testing.util import xfailif_windows + + +ACTUAL_GET_DEFAULT_VERSION = ruby.get_default_version.__wrapped__ + + +@pytest.fixture +def find_exe_mck(): + with mock.patch.object(parse_shebang, 'find_executable') as mck: + yield mck + + +def test_uses_default_version_when_not_available(find_exe_mck): + find_exe_mck.return_value = None + assert ACTUAL_GET_DEFAULT_VERSION() == C.DEFAULT + + +def test_uses_system_if_both_gem_and_ruby_are_available(find_exe_mck): + find_exe_mck.return_value = '/path/to/exe' + assert ACTUAL_GET_DEFAULT_VERSION() == 'system' -@xfailif_windows_no_ruby +@xfailif_windows # pragma: win32 no cover def test_install_rbenv(tempdir_factory): prefix = Prefix(tempdir_factory.get()) - ruby._install_rbenv(prefix) + ruby._install_rbenv(prefix, C.DEFAULT) # Should have created rbenv directory assert os.path.exists(prefix.path('rbenv-default')) @@ -18,7 +42,7 @@ def test_install_rbenv(tempdir_factory): cmd_output('rbenv', '--help') -@xfailif_windows_no_ruby +@xfailif_windows # pragma: win32 no cover def test_install_rbenv_with_version(tempdir_factory): prefix = Prefix(tempdir_factory.get()) ruby._install_rbenv(prefix, version='1.9.3p547') |