Skip to content

Commit 0e7732a

Browse files
committed
WIP
1 parent 9d0417c commit 0e7732a

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

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

+37-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,39 @@ 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 powershell");
124+
const stub = sinon.stub(vscode.env, "shell").returns(stdout.trim());
125+
126+
const { env, version, yjit } = await windows.activate();
127+
stub.restore();
128+
129+
assert.match(env.GEM_PATH!, /ruby\/3\.3\.0/);
130+
assert.match(env.GEM_PATH!, /lib\/ruby\/gems\/3\.3\.0/);
131+
assert.strictEqual(version, RUBY_VERSION);
132+
assert.notStrictEqual(yjit, undefined);
133+
134+
fs.rmSync(path.join("C:", `Ruby${major}${minor}-${os.arch()}`), {
135+
recursive: true,
136+
force: true,
137+
});
138+
});
103139
});

0 commit comments

Comments
 (0)