Skip to content

Commit

Permalink
Fully initialize global state in tests by calling apply_options
Browse files Browse the repository at this point in the history
As stated in this comment: #1926 (comment)
A global state is not fully initialized without `apply_options` being called,
which the current `with_server` test helper does not do.

This means that when tests are being run, detections around things like
test library are not performed, which can yield unexpected results to
developers, especially addon authors.

This commit changes the `with_server` test helper to call `apply_options`.
  • Loading branch information
st0012 committed May 31, 2024
1 parent 97ce82f commit 2f5f74d
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions lib/ruby_lsp/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def with_server(source = nil, uri = Kernel.URI("file:///fake.rb"), stub_no_typec
&block)
server = RubyLsp::Server.new(test_mode: true)
server.global_state.stubs(:typechecker).returns(false) if stub_no_typechecker
server.global_state.apply_options({})

if source
server.process_message({
Expand Down

0 comments on commit 2f5f74d

Please sign in to comment.