File tree Expand file tree Collapse file tree 4 files changed +48
-8
lines changed
lib/ruby_lsp/ruby_lsp_rails Expand file tree Collapse file tree 4 files changed +48
-8
lines changed Original file line number Diff line number Diff line change @@ -278,7 +278,7 @@ def read_response
278
278
raise IncompleteMessageError unless headers
279
279
280
280
content_length = headers [ /Content-Length: (\d +)/i , 1 ] . to_i
281
- raise EmptyMessageError if content_length . zero?
281
+ return if content_length . zero?
282
282
283
283
@stdout . read ( content_length )
284
284
end
Original file line number Diff line number Diff line change
1
+ # typed: true
2
+ # frozen_string_literal: true
3
+
4
+ require "test_helper"
5
+
6
+ module RubyLsp
7
+ module Rails
8
+ class LaunchTest < ActiveSupport ::TestCase
9
+ test "launching the client succeeds" do
10
+ outgoing_queue = Thread ::Queue . new
11
+
12
+ client = RunnerClient . create_client ( outgoing_queue )
13
+ refute_instance_of ( NullClient , client )
14
+
15
+ first = pop_log_notification ( outgoing_queue , Constant ::MessageType ::LOG )
16
+ assert_equal ( "Ruby LSP Rails booting server" , first . params . message )
17
+
18
+ second = pop_log_notification ( outgoing_queue , Constant ::MessageType ::LOG )
19
+ assert_match ( "Finished booting Ruby LSP Rails server" , second . params . message )
20
+
21
+ client . shutdown
22
+ assert_predicate ( client , :stopped? )
23
+ outgoing_queue . close
24
+ end
25
+ end
26
+ end
27
+ end
Original file line number Diff line number Diff line change @@ -87,17 +87,22 @@ class RunnerClientTest < ActiveSupport::TestCase
87
87
junk = %{\n puts "1\r \n \r \n hello"}
88
88
File . write ( "test/dummy/config/application.rb" , content + junk )
89
89
90
- capture_subprocess_io do
91
- outgoing_queue = Thread ::Queue . new
92
- client = RunnerClient . create_client ( outgoing_queue )
90
+ outgoing_queue = Thread ::Queue . new
91
+
92
+ client = RunnerClient . create_client ( outgoing_queue )
93
+ response = client . model ( "User" )
93
94
94
- response = T . must ( client . model ( "User" ) )
95
- assert ( response . key? ( :columns ) )
95
+ unless response
96
+ log = pop_log_notification ( outgoing_queue , RubyLsp ::Constant ::MessageType ::WARNING )
97
+ flunk ( "Model returned nil: #{ log . params . message } " )
98
+ end
99
+
100
+ begin
101
+ assert ( T . must ( response ) . key? ( :columns ) )
96
102
ensure
97
103
T . must ( outgoing_queue ) . close
104
+ FileUtils . mv ( "test/dummy/config/application.rb.bak" , "test/dummy/config/application.rb" )
98
105
end
99
- ensure
100
- FileUtils . mv ( "test/dummy/config/application.rb.bak" , "test/dummy/config/application.rb" )
101
106
end
102
107
103
108
test "delegate notification" do
Original file line number Diff line number Diff line change @@ -48,5 +48,13 @@ def pop_result(server)
48
48
)
49
49
T . cast ( result , RubyLsp ::Result )
50
50
end
51
+
52
+ def pop_log_notification ( message_queue , type )
53
+ log = message_queue . pop
54
+ return log if log . params . type == type
55
+
56
+ log = message_queue . pop until log . params . type == type
57
+ log
58
+ end
51
59
end
52
60
end
You can’t perform that action at this time.
0 commit comments