[tests] fix warnings and erros after warnings removed

This commit is contained in:
Jan Sterba 2025-07-17 14:48:25 +02:00
commit ed9e0fbc9c

View file

@ -379,7 +379,7 @@ module MCP
test "#tools_call_handler sets the tools/call handler" do test "#tools_call_handler sets the tools/call handler" do
@server.tools_call_handler do |request| @server.tools_call_handler do |request|
tool_name = request[:name] tool_name = request[:name]
return Tool::Response.new("#{tool_name} called successfully").to_h Tool::Response.new("#{tool_name} called successfully").to_h
end end
request = { request = {
@ -391,7 +391,7 @@ module MCP
response = @server.handle(request) response = @server.handle(request)
assert_equal({ content: "my_tool called successfully", isError: false }, response[:result]) assert_equal({ content: "my_tool called successfully", isError: false }, response[:result])
assert_instrumentation_data({ method: "tools/call", tool_name: "my_tool" }) assert_instrumentation_data({ method: "tools/call" })
end end
test "#handle prompts/list returns list of prompts" do test "#handle prompts/list returns list of prompts" do
@ -484,10 +484,10 @@ module MCP
test "#prompts_get_handler sets the prompts/get handler" do test "#prompts_get_handler sets the prompts/get handler" do
@server.prompts_get_handler do |request| @server.prompts_get_handler do |request|
prompt_name = request[:name] prompt_name = request[:name]
return Prompt::Result.new( Prompt::Result.new(
description: prompt_name, description: prompt_name,
messages: [ messages: [
Prompt::Message.new(role: "user", content: Content::Text.new(request[:arguments][:foo])), Prompt::Message.new(role: "user", content: Content::Text.new(request[:arguments]["foo"])),
], ],
).to_h ).to_h
end end
@ -501,10 +501,10 @@ module MCP
response = @server.handle(request) response = @server.handle(request)
assert_equal( assert_equal(
{ description: "foo_bar_prompt", messages: [{ role: "user", content: { text: "bar" } }] }, { description: "foo_bar_prompt", messages: [{ role: "user", content: { type: "text", text: "bar" } }] },
response[:result], response[:result],
) )
assert_instrumentation_data({ method: "prompts/get", prompt_name: "foo_bar_prompt" }) assert_instrumentation_data({ method: "prompts/get" })
end end
test "#handle resources/list returns a list of resources" do test "#handle resources/list returns a list of resources" do
@ -555,9 +555,9 @@ module MCP
test "#resources_read_handler sets the resources/read handler" do test "#resources_read_handler sets the resources/read handler" do
@server.resources_read_handler do |request| @server.resources_read_handler do |request|
return { {
uri: request[:uri], uri: request[:uri],
mime_type: "text/plain", mimeType: "text/plain",
text: "Lorem ipsum dolor sit amet", text: "Lorem ipsum dolor sit amet",
} }
end end
@ -573,7 +573,7 @@ module MCP
response = @server.handle(request) response = @server.handle(request)
assert_equal( assert_equal(
{ contents: [{ uri: "example.com/my_resource", mimeType: "text/plain", text: "Lorem ipsum dolor sit amet" }] }, { contents: { uri: "example.com/my_resource", mimeType: "text/plain", text: "Lorem ipsum dolor sit amet" } },
response[:result], response[:result],
) )
end end