ruby-sdk/test/model_context_protocol/tool/input_schema_test.rb
Tyler Rowsell baeb99ffbc Internal Release 0.7.0
- add support for resource templates
- improve capability negotiation on handlers
- clean up readme
- reduce default protocol version to "2024-11-05"
- address spec compliance of resources
- add debug gem to development
- alias ModelContextProtocol to MCP
- move prompt subclasses to subdir
- improve tool and prompt definition
- improve passing of server context to tools
- improve tool input schema validation
2025-05-08 17:38:19 -04:00

32 lines
1.3 KiB
Ruby

# frozen_string_literal: true
require "test_helper"
module ModelContextProtocol
class Tool
class InputSchemaTest < ActiveSupport::TestCase
test "required arguments are converted to symbols" do
input_schema = InputSchema.new(properties: { message: { type: "string" } }, required: ["message"])
assert_equal [:message], input_schema.required
end
test "to_h returns a hash representation of the input schema" do
input_schema = InputSchema.new(properties: { message: { type: "string" } }, required: [:message])
assert_equal(
{ type: "object", properties: { message: { type: "string" } }, required: [:message] },
input_schema.to_h,
)
end
test "missing_required_arguments returns an array of missing required arguments" do
input_schema = InputSchema.new(properties: { message: { type: "string" } }, required: [:message])
assert_equal [:message], input_schema.missing_required_arguments({})
end
test "missing_required_arguments returns an empty array if no required arguments are missing" do
input_schema = InputSchema.new(properties: { message: { type: "string" } }, required: [:message])
assert_equal [], input_schema.missing_required_arguments({ message: "Hello, world!" })
end
end
end
end