postmodern / chruby

Changes the current Ruby
MIT License
2.88k stars 189 forks source link

test breaks when .ruby-version present in ~ #264

Open JeanMertz opened 10 years ago

JeanMertz commented 10 years ago

@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.

postmodern commented 10 years ago

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

JeanMertz commented 10 years ago

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?

postmodern commented 10 years ago

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