ruby-sdk/test/model_context_protocol/tool_test.rb
Topher Bullock a4df3b8688 Internal Release v0.1.1
- implement `Prompt`
- adjust Tool approach
- update readme for tool calling
- document usage of `Prompt`
2025-05-08 17:37:27 -04:00

22 lines
789 B
Ruby

# frozen_string_literal: true
require "test_helper"
module ModelContextProtocol
class ToolTest < ActiveSupport::TestCase
test "#to_h returns a hash with name, description, and inputSchema" do
tool = Tool.new(name: "mock_tool", description: "a mock tool for testing")
assert_equal tool.to_h, { name: "mock_tool", description: "a mock tool for testing", inputSchema: nil }
end
test "#call invokes the tool block and returns the response" do
tool = Tool.new(name: "mock_tool", description: "a mock tool for testing") do |_|
Tool::Response.new([{ type: "text", content: "OK" }])
end
response = tool.call
assert_equal response.content, [{ type: "text", content: "OK" }]
assert_equal response.is_error, false
end
end
end