Rubocop
This commit is contained in:
parent
55b03fc7aa
commit
e546d76991
3 changed files with 16 additions and 16 deletions
|
|
@ -30,7 +30,7 @@ module MCP
|
||||||
nil # Simulate end of input
|
nil # Simulate end of input
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_encoding(encoding)
|
def set_encoding(encoding) # rubocop:disable Naming/AccessorMethodName
|
||||||
# Mock implementation
|
# Mock implementation
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -131,7 +131,7 @@ module MCP
|
||||||
@server.define_tool(
|
@server.define_tool(
|
||||||
name: "dynamic_tool",
|
name: "dynamic_tool",
|
||||||
description: "A dynamically added tool",
|
description: "A dynamically added tool",
|
||||||
) do |**args|
|
) do |**_args|
|
||||||
{ result: "success" }
|
{ result: "success" }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -213,7 +213,7 @@ module MCP
|
||||||
@server.define_prompt(
|
@server.define_prompt(
|
||||||
name: "test_prompt",
|
name: "test_prompt",
|
||||||
description: "Test prompt",
|
description: "Test prompt",
|
||||||
) do |args, server_context:|
|
) do |_args, _server_context:|
|
||||||
MCP::PromptResponse.new(messages: [{ role: "user", content: "Test" }])
|
MCP::PromptResponse.new(messages: [{ role: "user", content: "Test" }])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -181,7 +181,7 @@ module MCP
|
||||||
@server.define_tool(
|
@server.define_tool(
|
||||||
name: "dynamic_tool",
|
name: "dynamic_tool",
|
||||||
description: "A dynamically added tool",
|
description: "A dynamically added tool",
|
||||||
) do |**args|
|
) do |**_args|
|
||||||
{ result: "success" }
|
{ result: "success" }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,13 +29,13 @@ module MCP
|
||||||
setup do
|
setup do
|
||||||
configuration = MCP::Configuration.new
|
configuration = MCP::Configuration.new
|
||||||
configuration.instrumentation_callback = instrumentation_helper.callback
|
configuration.instrumentation_callback = instrumentation_helper.callback
|
||||||
|
|
||||||
@server = Server.new(
|
@server = Server.new(
|
||||||
name: "test_server",
|
name: "test_server",
|
||||||
version: "1.0.0",
|
version: "1.0.0",
|
||||||
configuration: configuration
|
configuration: configuration,
|
||||||
)
|
)
|
||||||
|
|
||||||
@mock_transport = MockTransport.new(@server)
|
@mock_transport = MockTransport.new(@server)
|
||||||
@server.transport = @mock_transport
|
@server.transport = @mock_transport
|
||||||
end
|
end
|
||||||
|
|
@ -69,7 +69,7 @@ module MCP
|
||||||
|
|
||||||
test "notification methods work without transport" do
|
test "notification methods work without transport" do
|
||||||
server_without_transport = Server.new(name: "test_server")
|
server_without_transport = Server.new(name: "test_server")
|
||||||
|
|
||||||
# Should not raise any errors
|
# Should not raise any errors
|
||||||
assert_nothing_raised do
|
assert_nothing_raised do
|
||||||
server_without_transport.notify_tools_list_changed
|
server_without_transport.notify_tools_list_changed
|
||||||
|
|
@ -85,16 +85,16 @@ module MCP
|
||||||
raise StandardError, "Transport error"
|
raise StandardError, "Transport error"
|
||||||
end
|
end
|
||||||
end.new(@server)
|
end.new(@server)
|
||||||
|
|
||||||
@server.transport = error_transport
|
@server.transport = error_transport
|
||||||
|
|
||||||
# Mock the exception reporter
|
# Mock the exception reporter
|
||||||
expected_contexts = [
|
expected_contexts = [
|
||||||
{ notification: "tools_list_changed" },
|
{ notification: "tools_list_changed" },
|
||||||
{ notification: "prompts_list_changed" },
|
{ notification: "prompts_list_changed" },
|
||||||
{ notification: "resources_list_changed" }
|
{ notification: "resources_list_changed" },
|
||||||
]
|
]
|
||||||
|
|
||||||
call_count = 0
|
call_count = 0
|
||||||
@server.configuration.exception_reporter.expects(:call).times(3).with do |exception, context|
|
@server.configuration.exception_reporter.expects(:call).times(3).with do |exception, context|
|
||||||
assert_kind_of StandardError, exception
|
assert_kind_of StandardError, exception
|
||||||
|
|
@ -103,14 +103,14 @@ module MCP
|
||||||
call_count += 1
|
call_count += 1
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
# Should not raise errors to the caller
|
# Should not raise errors to the caller
|
||||||
assert_nothing_raised do
|
assert_nothing_raised do
|
||||||
@server.notify_tools_list_changed
|
@server.notify_tools_list_changed
|
||||||
@server.notify_prompts_list_changed
|
@server.notify_prompts_list_changed
|
||||||
@server.notify_resources_list_changed
|
@server.notify_resources_list_changed
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_equal 3, call_count
|
assert_equal 3, call_count
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -120,7 +120,7 @@ module MCP
|
||||||
@server.notify_resources_list_changed
|
@server.notify_resources_list_changed
|
||||||
|
|
||||||
assert_equal 3, @mock_transport.notifications.size
|
assert_equal 3, @mock_transport.notifications.size
|
||||||
|
|
||||||
notifications = @mock_transport.notifications
|
notifications = @mock_transport.notifications
|
||||||
assert_equal Methods::NOTIFICATIONS_TOOLS_LIST_CHANGED, notifications[0][:method]
|
assert_equal Methods::NOTIFICATIONS_TOOLS_LIST_CHANGED, notifications[0][:method]
|
||||||
assert_equal Methods::NOTIFICATIONS_PROMPTS_LIST_CHANGED, notifications[1][:method]
|
assert_equal Methods::NOTIFICATIONS_PROMPTS_LIST_CHANGED, notifications[1][:method]
|
||||||
|
|
@ -133,4 +133,4 @@ module MCP
|
||||||
assert_equal "notifications/resources/list_changed", Methods::NOTIFICATIONS_RESOURCES_LIST_CHANGED
|
assert_equal "notifications/resources/list_changed", Methods::NOTIFICATIONS_RESOURCES_LIST_CHANGED
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue