|
1 | 1 | import os.path |
2 | | -import shlex |
3 | 2 |
|
4 | | -from pre_commit.languages.ruby import _install_rbenv |
| 3 | +from pre_commit.languages import ruby |
5 | 4 | from pre_commit.prefix import Prefix |
6 | 5 | from pre_commit.util import cmd_output |
7 | 6 | from testing.util import xfailif_windows_no_ruby |
|
10 | 9 | @xfailif_windows_no_ruby |
11 | 10 | def test_install_rbenv(tempdir_factory): |
12 | 11 | prefix = Prefix(tempdir_factory.get()) |
13 | | - _install_rbenv(prefix) |
| 12 | + ruby._install_rbenv(prefix) |
14 | 13 | # Should have created rbenv directory |
15 | 14 | assert os.path.exists(prefix.path('rbenv-default')) |
16 | | - # We should have created our `activate` script |
17 | | - activate_path = prefix.path('rbenv-default', 'bin', 'activate') |
18 | | - assert os.path.exists(activate_path) |
19 | 15 |
|
20 | 16 | # Should be able to activate using our script and access rbenv |
21 | | - cmd_output( |
22 | | - 'bash', '-c', |
23 | | - '. {} && rbenv --help'.format( |
24 | | - shlex.quote(prefix.path('rbenv-default', 'bin', 'activate')), |
25 | | - ), |
26 | | - ) |
| 17 | + with ruby.in_env(prefix, 'default'): |
| 18 | + cmd_output('rbenv', '--help') |
27 | 19 |
|
28 | 20 |
|
29 | 21 | @xfailif_windows_no_ruby |
30 | 22 | def test_install_rbenv_with_version(tempdir_factory): |
31 | 23 | prefix = Prefix(tempdir_factory.get()) |
32 | | - _install_rbenv(prefix, version='1.9.3p547') |
| 24 | + ruby._install_rbenv(prefix, version='1.9.3p547') |
33 | 25 |
|
34 | 26 | # Should be able to activate and use rbenv install |
35 | | - cmd_output( |
36 | | - 'bash', '-c', |
37 | | - '. {} && rbenv install --help'.format( |
38 | | - shlex.quote(prefix.path('rbenv-1.9.3p547', 'bin', 'activate')), |
39 | | - ), |
40 | | - ) |
| 27 | + with ruby.in_env(prefix, '1.9.3p547'): |
| 28 | + cmd_output('rbenv', 'install', '--help') |
0 commit comments