Skip to content

Commit

Permalink
Prevent stub being lost
Browse files Browse the repository at this point in the history
  • Loading branch information
andyw8 committed Sep 29, 2023
1 parent 1d79525 commit b53d10d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion test/executor_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions test/requests/code_lens_expectations_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion test/requests/support/dependency_detector_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit b53d10d

Please sign in to comment.