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..e96a7f2d 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -63,5 +63,11 @@ def pop_message(outgoing_queue, &block) message = outgoing_queue.pop until block.call(message) message end + + def wait_for_rails_to_boot + while RubyLsp::Addon.addons.first.instance_variable_get(:@rails_runner_client).is_a?(RubyLsp::Rails::NullClient) + sleep(0.1) + end + end end end