@@ -14,7 +14,7 @@ import { LOG_CHANNEL, asyncExec } from "../../common";
1414import { RUBY_VERSION } from "../rubyVersion" ;
1515
1616import { FAKE_TELEMETRY } from "./fakeTelemetry" ;
17- import { createRubySymlinks } from "./helpers" ;
17+ import { createRubySymlinks , fakeContext } from "./helpers" ;
1818
1919suite ( "Debugger" , ( ) => {
2020 const original = vscode . workspace
@@ -34,7 +34,7 @@ suite("Debugger", () => {
3434 } ) ;
3535
3636 test ( "Provide debug configurations returns the default configs" , ( ) => {
37- const context = { subscriptions : [ ] } as unknown as vscode . ExtensionContext ;
37+ const context = fakeContext ( ) ;
3838 const debug = new Debugger ( context , ( ) => {
3939 return undefined ;
4040 } ) ;
@@ -69,7 +69,7 @@ suite("Debugger", () => {
6969 } ) ;
7070
7171 test ( "Resolve configuration injects Ruby environment" , async ( ) => {
72- const context = { subscriptions : [ ] } as unknown as vscode . ExtensionContext ;
72+ const context = fakeContext ( ) ;
7373 const ruby = { env : { bogus : "hello!" } } as unknown as Ruby ;
7474 const workspaceFolder = {
7575 name : "fake" ,
@@ -99,7 +99,7 @@ suite("Debugger", () => {
9999 } ) ;
100100
101101 test ( "Resolve configuration injects Ruby environment and allows users custom environment" , async ( ) => {
102- const context = { subscriptions : [ ] } as unknown as vscode . ExtensionContext ;
102+ const context = fakeContext ( ) ;
103103 const ruby = { env : { bogus : "hello!" } } as unknown as Ruby ;
104104 const workspaceFolder = {
105105 name : "fake" ,
@@ -134,7 +134,7 @@ suite("Debugger", () => {
134134 fs . mkdirSync ( path . join ( tmpPath , ".ruby-lsp" ) ) ;
135135 fs . writeFileSync ( path . join ( tmpPath , ".ruby-lsp" , "Gemfile" ) , "hello!" ) ;
136136
137- const context = { subscriptions : [ ] } as unknown as vscode . ExtensionContext ;
137+ const context = fakeContext ( ) ;
138138 const ruby = { env : { bogus : "hello!" } } as unknown as Ruby ;
139139 const workspaceFolder = {
140140 name : "fake" ,
@@ -198,15 +198,7 @@ suite("Debugger", () => {
198198 'source "https://rubygems.org"\ngem "debug"' ,
199199 ) ;
200200
201- const extensionPath = path . dirname ( path . dirname ( path . dirname ( __dirname ) ) ) ;
202- const context = {
203- subscriptions : [ ] ,
204- workspaceState : {
205- get : ( ) => undefined ,
206- update : ( ) => undefined ,
207- } ,
208- extensionUri : vscode . Uri . file ( extensionPath ) ,
209- } as unknown as vscode . ExtensionContext ;
201+ const context = fakeContext ( ) ;
210202 const outputChannel = new WorkspaceChannel ( "fake" , LOG_CHANNEL ) ;
211203 const workspaceFolder : vscode . WorkspaceFolder = {
212204 uri : vscode . Uri . file ( tmpPath ) ,
@@ -247,6 +239,7 @@ suite("Debugger", () => {
247239 name : "Debug" ,
248240 request : "launch" ,
249241 program : `ruby ${ path . join ( tmpPath , "test.rb" ) } ` ,
242+ workspaceFolder,
250243 } ) ;
251244 } catch ( error : any ) {
252245 assert . fail ( `Failed to launch debugger: ${ error . message } ` ) ;
0 commit comments