Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid stubbing File.read to prevent flaky tests #2980

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions test/server_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -439,16 +439,21 @@ def test_backtrace_is_printed_to_stderr_on_exceptions
end

def test_changed_file_only_indexes_ruby
File.expects(:read).with("/foo.rb").returns("class Foo\nend")
path = File.join(Dir.pwd, "lib", "foo.rb")
File.write(path, "class Foo\nend")

@server.global_state.index.expects(:index_single).once.with do |uri|
uri.full_path == "/foo.rb"
uri.full_path == path
end

uri = URI::Generic.from_path(path: path)

@server.process_message({
method: "workspace/didChangeWatchedFiles",
params: {
changes: [
{
uri: URI("file:///foo.rb"),
uri: uri,
type: RubyLsp::Constant::FileChangeType::CREATED,
},
{
Expand All @@ -458,6 +463,8 @@ def test_changed_file_only_indexes_ruby
],
},
})
ensure
FileUtils.rm(T.must(path))
end

def test_workspace_addons
Expand Down
Loading