@@ -20,30 +20,26 @@ class Anyenv < Formula
2020 end
2121
2222 def install
23+ inreplace "libexec/anyenv" , "/usr/local" , HOMEBREW_PREFIX
2324 prefix . install %w[ bin completions libexec ]
2425 end
2526
2627 test do
27- Dir . mktmpdir do |dir |
28- profile = "#{ dir } /.profile"
29- File . open ( profile , "w" ) do |f |
30- content = <<~SHELL
31- export ANYENV_ROOT=#{ dir } /anyenv
32- export ANYENV_DEFINITION_ROOT=#{ dir } /anyenv-install
33- eval "$(anyenv init -)"
34- SHELL
35- f . write ( content )
36- end
28+ anyenv_root = testpath /"anyenv"
29+ profile = testpath /".profile"
30+ profile . write <<~SHELL
31+ export ANYENV_ROOT=#{ anyenv_root }
32+ export ANYENV_DEFINITION_ROOT=#{ testpath } /anyenv-install
33+ eval "$(#{ bin } /anyenv init -)"
34+ SHELL
3735
38- cmds = <<~SHELL
39- anyenv install --force-init
40- anyenv install --list
41- anyenv install rbenv
42- rbenv install --list
43- SHELL
44- cmds . split ( "\n " ) . each do |cmd |
45- shell_output ( ". #{ profile } && #{ cmd } " )
46- end
47- end
36+ anyenv_install = ". #{ profile } && #{ bin } /anyenv install"
37+ assert_match "Completed!" , shell_output ( "#{ anyenv_install } --force-init" )
38+ assert_match ( /^\s *rbenv$/ , shell_output ( "#{ anyenv_install } --list" ) )
39+ assert_match "succeeded!" , shell_output ( "#{ anyenv_install } rbenv" )
40+
41+ anyenv_rbenv_path = "#{ anyenv_root } /envs/rbenv/bin/rbenv"
42+ assert_equal anyenv_rbenv_path , shell_output ( ". #{ profile } && which rbenv" ) . chomp
43+ assert_match ( /^\d +\. \d +\. \d +$/ , shell_output ( ". #{ profile } && rbenv install --list" ) )
4844 end
4945end
0 commit comments