Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update readme for rvm #98

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ If the extension doesn't work for you, here are a few things you can try:
- If you're using RSpec, make sure you're using a recent version of the `rspec-core` gem. If you're on a version prior to 3.6.0, the extension may not work.
- If you're using RSpec, make sure that the RSpec command and `spec` directory are configured correctly. By default, tests are run with `bundle exec rspec` and the tests are assumed to be in the `./spec/` directory. You can configure these with `rubyTestExplorer.rspecCommand` and `rubyTestExplorer.rspecDirectory` respectively.
- If the test suite info isn't loading, your `testFramework` config may be set to `none` or the auto-detect may be failing to determine the test framework. Try setting the `testFramework` config to `rspec` or `minitest` depending on what you want to use.
- If you are using rvm you may need to manually specify the gemset `rvm use 2.5.0@gemset_name do ./bin/rspec` for example

If all else fails or you suspect something is broken with the extension, please feel free to open an issue! :)

Expand Down
38 changes: 34 additions & 4 deletions src/minitestTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,42 @@ export class MinitestTests extends Tests {
*
* @return The env
*/

protected getProcessEnv(): any {
let envPath: string = process.env.PATH;
let newPath: string = envPath;

let newGemPath: string = process.env.GEM_PATH;
let newGemHome: string = process.env.GEM_HOME

let vscodeRubyPath: string = vscode.workspace.getConfiguration('ruby', null).get('interpreter.commandPath').replace(/ruby$/,'');
let rvmPattern = new RegExp('/.rvm/rubies/(ruby-[^/]*)/'); // check if rvm is used, extract ruby verision
if( vscodeRubyPath.match(rvmPattern) && envPath.match(rvmPattern) ) {
let vscodeRubyVersion: string = vscodeRubyPath.match(rvmPattern)[1];
let envRubyVersion: string = envPath.match(rvmPattern)[1];
this.log.info(`checking ruby versions in vs code config '${vscodeRubyVersion}' vs env ${envRubyVersion}`);
if( vscodeRubyVersion != envRubyVersion ) {
this.log.info(`replace all refrences to ${envRubyVersion} with '${vscodeRubyVersion} in env:`);
// replaceAll still not working in node.js, we have 3 occurences
newPath = envPath.replace(envRubyVersion, vscodeRubyVersion)
.replace(envRubyVersion, vscodeRubyVersion)
.replace(envRubyVersion, vscodeRubyVersion);
this.log.info(`constructed new PATH ${newPath}`);
newGemPath = newGemPath.replace(envRubyVersion, vscodeRubyVersion);
this.log.info(`constructed new GEM_PATH ${newGemPath}`);
newGemHome = newGemHome.replace(envRubyVersion, vscodeRubyVersion);
this.log.info(`constructed new GEM_HOME ${newGemHome}`);
}
}

return Object.assign({}, process.env, {
"RAILS_ENV": "test",
"EXT_DIR": this.getRubyScriptsLocation(),
"TESTS_DIR": this.getTestDirectory(),
"TESTS_PATTERN": this.getFilePattern().join(',')
"RAILS_ENV": "test",
"EXT_DIR": this.getRubyScriptsLocation(),
"TESTS_DIR": this.getTestDirectory(),
"TESTS_PATTERN": this.getFilePattern().join(','),
"PATH": newPath,
"GEM_PATH": newGemPath,
"GEM_HOME": newGemHome
});
}

Expand Down