There are at a couple of undocumented requirements to run the tests. At least:
We could maybe create a directory in ./test/ with shell rc files that load our version of chruby, and point HOME there. chruby_auto would still escape to parent directories to search for .ruby-version.
Then maybe the TEST_RUBY_ROOT could be configurable and other TEST_RUBY_* variable parsed from it. And maybe even use a fake ruby executable that only prints the output needed by chruby_use? Unfortunately then it would be difficult to catch regressions in chruby_use.
Overall it would be nice to modify the test setup more independent and maybe have even automatic Travis tests.
I like the idea of setting up a mock home. We would have to test against a live install of Ruby. We could manually download/build MRI in our mock directory?
We could even setup make tasks to create the mock homedir and install a Ruby into it.
Good idea. The whole test dir tree could be generated. We could also add a test that fails if .ruby-version is found on some parent directory.
Using a tempdir would be nice but compiling and installing the ruby on each run is not an option.
Tests now run the shell without loading the shell rc files.
Tests are now fully isolated from the system. test/setup will download a precompiled Ruby and extract it into test/rubies/. We also set HOME to test/home/ so that it's .bashrc/.zsh is loaded when chruby-exec executes the sub-shell.