Skip to content

Commit 83c12c7

Browse files
committed
WIP
1 parent 9d0417c commit 83c12c7

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

vscode/src/test/suite/ruby/rubyInstaller.test.ts

+39-1
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ import assert from "assert";
33
import path from "path";
44
import os from "os";
55

6+
import sinon from "sinon";
67
import { before, after } from "mocha";
78
import * as vscode from "vscode";
89

910
import { RubyInstaller } from "../../../ruby/rubyInstaller";
1011
import { WorkspaceChannel } from "../../../workspaceChannel";
11-
import { LOG_CHANNEL } from "../../../common";
12+
import { asyncExec, LOG_CHANNEL } from "../../../common";
1213
import { RUBY_VERSION } from "../../rubyVersion";
1314

1415
suite("RubyInstaller", () => {
@@ -100,4 +101,41 @@ suite("RubyInstaller", () => {
100101
force: true,
101102
});
102103
});
104+
105+
test("Finds Ruby using Powershell", async () => {
106+
const [major, minor, _patch] = RUBY_VERSION.split(".").map(Number);
107+
fs.symlinkSync(
108+
path.join(
109+
"C:",
110+
"hostedtoolcache",
111+
"windows",
112+
"Ruby",
113+
RUBY_VERSION,
114+
"x64",
115+
),
116+
path.join("C:", `Ruby${major}${minor}-${os.arch()}`),
117+
);
118+
119+
fs.writeFileSync(path.join(workspacePath, ".ruby-version"), RUBY_VERSION);
120+
121+
const windows = new RubyInstaller(workspaceFolder, outputChannel);
122+
123+
const { stdout } = await asyncExec("where.exe powershell");
124+
// eslint-disable-next-line no-console
125+
console.log(stdout);
126+
const stub = sinon.stub(vscode.env, "shell").returns(stdout.trim());
127+
128+
const { env, version, yjit } = await windows.activate();
129+
stub.restore();
130+
131+
assert.match(env.GEM_PATH!, /ruby\/3\.3\.0/);
132+
assert.match(env.GEM_PATH!, /lib\/ruby\/gems\/3\.3\.0/);
133+
assert.strictEqual(version, RUBY_VERSION);
134+
assert.notStrictEqual(yjit, undefined);
135+
136+
fs.rmSync(path.join("C:", `Ruby${major}${minor}-${os.arch()}`), {
137+
recursive: true,
138+
force: true,
139+
});
140+
});
103141
});

0 commit comments

Comments
 (0)