@@ -8,9 +8,10 @@ import * as vscode from "vscode";
88import { beforeEach , afterEach } from "mocha" ;
99
1010import { Workspace } from "../../workspace" ;
11+ import * as common from "../../common" ;
1112
1213import { FAKE_TELEMETRY } from "./fakeTelemetry" ;
13- import { createContext , FakeContext } from "./helpers" ;
14+ import { createContext , FakeContext , stubWorkspaceConfiguration } from "./helpers" ;
1415
1516suite ( "Workspace" , ( ) => {
1617 let workspacePath : string ;
@@ -41,6 +42,50 @@ suite("Workspace", () => {
4142 context . dispose ( ) ;
4243 } ) ;
4344
45+ test ( "installs ruby-lsp with env shebang" , async ( ) => {
46+ stubWorkspaceConfiguration ( sandbox , { rubyLsp : { bundleGemfile : "" } } ) ;
47+ sandbox . stub ( common , "featureEnabled" ) . returns ( false ) ;
48+
49+ const execStub = sandbox . stub ( common , "asyncExec" ) ;
50+ execStub . onFirstCall ( ) . resolves ( { stdout : "" , stderr : "" } ) ;
51+ execStub . onSecondCall ( ) . resolves ( { stdout : "" , stderr : "" } ) ;
52+
53+ await workspace . installOrUpdateServer ( false ) ;
54+
55+ assert . strictEqual ( execStub . firstCall . args [ 0 ] , "gem list ruby-lsp language_server-protocol prism rbs" ) ;
56+ assert . strictEqual ( execStub . secondCall . args [ 0 ] , "gem install ruby-lsp --env-shebang" ) ;
57+ } ) ;
58+
59+ test ( "updates ruby-lsp with env shebang" , async ( ) => {
60+ stubWorkspaceConfiguration ( sandbox , { rubyLsp : { bundleGemfile : "" } } ) ;
61+ sandbox . stub ( common , "featureEnabled" ) . returns ( false ) ;
62+
63+ const execStub = sandbox . stub ( common , "asyncExec" ) ;
64+ execStub . onFirstCall ( ) . resolves ( {
65+ stdout : "ruby-lsp (0.1.0)\nlanguage_server-protocol (3.17.0)\nprism (1.2.0)\nrbs (3.0.0)\n" ,
66+ stderr : "" ,
67+ } ) ;
68+ execStub . onSecondCall ( ) . resolves ( { stdout : "" , stderr : "" } ) ;
69+
70+ await workspace . installOrUpdateServer ( false ) ;
71+
72+ assert . strictEqual ( execStub . firstCall . args [ 0 ] , "gem list ruby-lsp language_server-protocol prism rbs" ) ;
73+ assert . strictEqual ( execStub . secondCall . args [ 0 ] , "gem update ruby-lsp --env-shebang" ) ;
74+ } ) ;
75+
76+ test ( "installs beta ruby-lsp with prerelease and env shebang flags" , async ( ) => {
77+ stubWorkspaceConfiguration ( sandbox , { rubyLsp : { bundleGemfile : "" } } ) ;
78+ sandbox . stub ( common , "featureEnabled" ) . returns ( true ) ;
79+
80+ const execStub = sandbox . stub ( common , "asyncExec" ) ;
81+ execStub . onFirstCall ( ) . resolves ( { stdout : "" , stderr : "" } ) ;
82+ execStub . onSecondCall ( ) . resolves ( { stdout : "" , stderr : "" } ) ;
83+
84+ await workspace . installOrUpdateServer ( false ) ;
85+
86+ assert . strictEqual ( execStub . secondCall . args [ 0 ] , "gem install ruby-lsp --pre --env-shebang" ) ;
87+ } ) ;
88+
4489 test ( "repeated rebase steps don't trigger multiple restarts" , async ( ) => {
4590 const gitDir = path . join ( workspacePath , ".git" ) ;
4691 fs . mkdirSync ( gitDir ) ;
0 commit comments