@@ -30,23 +30,45 @@ def test_uses_system_if_both_gem_and_ruby_are_available(find_exe_mck):
3030 assert ACTUAL_GET_DEFAULT_VERSION () == 'system'
3131
3232
33+ @pytest .fixture
34+ def fake_gem_prefix (tmpdir ):
35+ gemspec = '''\
36+ Gem::Specification.new do |s|
37+ s.name = 'pre_commit_dummy_package'
38+ s.version = '0.0.0'
39+ s.summary = 'dummy gem for pre-commit hooks'
40+ s.authors = ['Anthony Sottile']
41+ end
42+ '''
43+ tmpdir .join ('dummy_gem.gemspec' ).write (gemspec )
44+ yield Prefix (tmpdir )
45+
46+
47+ @xfailif_windows # pragma: win32 no cover
48+ def test_install_ruby_system (fake_gem_prefix ):
49+ ruby .install_environment (fake_gem_prefix , 'system' , ())
50+
51+ # Should be able to activate and use rbenv install
52+ with ruby .in_env (fake_gem_prefix , 'system' ):
53+ _ , out , _ = cmd_output ('gem' , 'list' )
54+ assert 'pre_commit_dummy_package' in out
55+
56+
3357@xfailif_windows # pragma: win32 no cover
34- def test_install_rbenv (tempdir_factory ):
35- prefix = Prefix (tempdir_factory .get ())
36- ruby ._install_rbenv (prefix , C .DEFAULT )
58+ def test_install_ruby_default (fake_gem_prefix ):
59+ ruby .install_environment (fake_gem_prefix , C .DEFAULT , ())
3760 # Should have created rbenv directory
38- assert os .path .exists (prefix .path ('rbenv-default' ))
61+ assert os .path .exists (fake_gem_prefix .path ('rbenv-default' ))
3962
4063 # Should be able to activate using our script and access rbenv
41- with ruby .in_env (prefix , 'default' ):
64+ with ruby .in_env (fake_gem_prefix , 'default' ):
4265 cmd_output ('rbenv' , '--help' )
4366
4467
4568@xfailif_windows # pragma: win32 no cover
46- def test_install_rbenv_with_version (tempdir_factory ):
47- prefix = Prefix (tempdir_factory .get ())
48- ruby ._install_rbenv (prefix , version = '1.9.3p547' )
69+ def test_install_ruby_with_version (fake_gem_prefix ):
70+ ruby .install_environment (fake_gem_prefix , '2.7.2' , ())
4971
5072 # Should be able to activate and use rbenv install
51- with ruby .in_env (prefix , '1.9.3p547 ' ):
73+ with ruby .in_env (fake_gem_prefix , '2.7.2 ' ):
5274 cmd_output ('rbenv' , 'install' , '--help' )
0 commit comments