From 5e845b06662af222ae6a2267ae1ae4d5b193927d Mon Sep 17 00:00:00 2001 From: Andy Waite <13400+andyw8@users.noreply.github.com> Date: Thu, 12 Dec 2024 16:05:17 -0500 Subject: [PATCH] Extract helper 'wait_for_rails_to_boot' --- test/ruby_lsp_rails/code_lens_test.rb | 2 +- test/ruby_lsp_rails/definition_test.rb | 2 +- test/test_helper.rb | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/test/ruby_lsp_rails/code_lens_test.rb b/test/ruby_lsp_rails/code_lens_test.rb index 30a769d2..7fd6d20c 100644 --- a/test/ruby_lsp_rails/code_lens_test.rb +++ b/test/ruby_lsp_rails/code_lens_test.rb @@ -402,7 +402,7 @@ def index def generate_code_lens_for_source(source, file: "/fake.rb") with_server(source, URI(file)) do |server, uri| - sleep(0.1) while RubyLsp::Addon.addons.first.instance_variable_get(:@rails_runner_client).is_a?(NullClient) + wait_for_rails_to_boot server.process_message( id: 1, diff --git a/test/ruby_lsp_rails/definition_test.rb b/test/ruby_lsp_rails/definition_test.rb index 581cb10a..84e52879 100644 --- a/test/ruby_lsp_rails/definition_test.rb +++ b/test/ruby_lsp_rails/definition_test.rb @@ -225,7 +225,7 @@ def baz; end def generate_definitions_for_source(source, position) with_server(source) do |server, uri| - sleep(0.1) while RubyLsp::Addon.addons.first.instance_variable_get(:@rails_runner_client).is_a?(NullClient) + wait_for_rails_to_boot server.process_message( id: 1, diff --git a/test/test_helper.rb b/test/test_helper.rb index ca2195c5..421c197c 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -63,5 +63,9 @@ def pop_message(outgoing_queue, &block) message = outgoing_queue.pop until block.call(message) message end + + def wait_for_rails_to_boot + sleep(0.1) while RubyLsp::Addon.addons.first.instance_variable_get(:@rails_runner_client).is_a?(NullClient) + end end end