chruby icon indicating copy to clipboard operation
chruby copied to clipboard

test breaks when .ruby-version present in ~

Open JeanMertz opened this issue 10 years ago • 3 comments

@postmodern looking at this test:

https://github.com/postmodern/chruby/blob/master/test/chruby_auto_test.sh#L102-L109

function test_chruby_auto_leave_project_dir()
{
    cd "$test_project_dir"    && chruby_auto
    cd "$test_project_dir/.." && chruby_auto

    assertNull "did not reset the Ruby when leaving a versioned directory" \
           "$RUBY_ROOT"
}

it seems (I haven't tested this in chruby yet, but I am seeing this result in my chruby-fish wrapper) that this test will fail if you have the repo installed somewhere that has a .ruby-version file somewhere in the directories above.

Not really sure what to do about it, except running the test from somewhere other than your home directory.

Just a heads-up.

JeanMertz avatar Apr 26 '14 10:04 JeanMertz

Make sure that you exported HOME, so the bash process that runs chruby also runs in an test home directory.

postmodern avatar Apr 27 '14 21:04 postmodern

granted, I haven't run these tests yet, only the fish-equivalent

But would the HOME path matter in this case? $test_project_dir lives outside of the test HOME and even if it did, HOME doesn't have to be a root path. For example:

$ cat /Users/Jean/.ruby-version
1.9

$ echo $HOME
/Users/Jean/code/oss/chruby-fish/test/home

# the below is hypothetical, since the test actually looks in test/project/.ruby-version
$ cat /Users/Jean/code/oss/chruby-fish/test/home/.ruby-version
2.1

$ cd /Users/Jean/code/oss/chruby-fish/test/home/.ruby-version
$ chruby_auto
2.1

$ cd ..
$ chruby_auto
1.9

chruby_auto doesn't stop at $HOME/~, it goes all the way to /, doesn't it?

JeanMertz avatar Apr 28 '14 09:04 JeanMertz

@JeanMertz ah ha, I see what you mean. Perhaps chruby_auto should respect $PREFIX and stop once it reaches the $PREFIX.

postmodern avatar Apr 28 '14 20:04 postmodern