diff --git a/test/executor_test.rb b/test/executor_test.rb index dd45176604..d353f3fd70 100644 --- a/test/executor_test.rb +++ b/test/executor_test.rb @@ -247,10 +247,10 @@ def unload_rubocop_runner end def stub_dependencies(rubocop:, syntax_tree:) + Singleton.__init__(RubyLsp::DependencyDetector) dependencies = {} dependencies["syntax_tree"] = "..." if syntax_tree dependencies["rubocop"] = "..." if rubocop Bundler.locked_gems.stubs(:dependencies).returns(dependencies) - Singleton.__init__(RubyLsp::DependencyDetector) end end diff --git a/test/requests/code_lens_expectations_test.rb b/test/requests/code_lens_expectations_test.rb index 9d294e3b4d..c9846d3a4f 100644 --- a/test/requests/code_lens_expectations_test.rb +++ b/test/requests/code_lens_expectations_test.rb @@ -19,6 +19,7 @@ def run_expectations(source) end def test_command_generation_for_test_unit + stub_test_library("test-unit") source = <<~RUBY class FooTest < Test::Unit::TestCase def test_bar; end @@ -29,7 +30,6 @@ def test_bar; end document = RubyLsp::Document.new(source: source, version: 1, uri: uri) emitter = RubyLsp::EventEmitter.new - stub_test_library("test-unit") listener = RubyLsp::Requests::CodeLens.new(uri, emitter, @message_queue) emitter.visit(document.tree) response = listener.response @@ -161,7 +161,7 @@ def on_class(node) end def stub_test_library(name) - RubyLsp::DependencyDetector.instance.stubs(:detected_test_library).returns(name) Singleton.__init__(RubyLsp::DependencyDetector) + RubyLsp::DependencyDetector.instance.stubs(:detected_test_library).returns(name) end end diff --git a/test/requests/support/dependency_detector_test.rb b/test/requests/support/dependency_detector_test.rb index 5d197f6f53..ad837c70d3 100644 --- a/test/requests/support/dependency_detector_test.rb +++ b/test/requests/support/dependency_detector_test.rb @@ -47,8 +47,8 @@ def test_direct_dependency_returns_false_outside_of_bundle private def stub_dependencies(dependencies) - Bundler.locked_gems.stubs(dependencies: dependencies) Singleton.__init__(RubyLsp::DependencyDetector) + Bundler.locked_gems.stubs(dependencies: dependencies) end end end