Class: ModelContextProtocol::RSpec::Matchers::BeValidMcpToolResponse
- Inherits:
-
Object
- Object
- ModelContextProtocol::RSpec::Matchers::BeValidMcpToolResponse
- Defined in:
- lib/model_context_protocol/rspec/matchers/be_valid_mcp_tool_response.rb
Constant Summary collapse
- MCP_CONTENT_TYPES =
%w[text image audio resource resource_link].freeze
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize ⇒ BeValidMcpToolResponse
constructor
A new instance of BeValidMcpToolResponse.
- #matches?(actual) ⇒ Boolean
Constructor Details
#initialize ⇒ BeValidMcpToolResponse
Returns a new instance of BeValidMcpToolResponse.
18 19 20 |
# File 'lib/model_context_protocol/rspec/matchers/be_valid_mcp_tool_response.rb', line 18 def initialize @failure_reasons = [] end |
Instance Method Details
#description ⇒ Object
43 44 45 |
# File 'lib/model_context_protocol/rspec/matchers/be_valid_mcp_tool_response.rb', line 43 def description "be a valid MCP tool response" end |
#failure_message ⇒ Object
34 35 36 37 |
# File 'lib/model_context_protocol/rspec/matchers/be_valid_mcp_tool_response.rb', line 34 def "expected #{@actual.class} to be a valid MCP tool response, but:\n" + @failure_reasons.map { |reason| " - #{reason}" }.join("\n") end |
#failure_message_when_negated ⇒ Object
39 40 41 |
# File 'lib/model_context_protocol/rspec/matchers/be_valid_mcp_tool_response.rb', line 39 def "expected #{@actual.class} not to be a valid MCP tool response, but it was" end |
#matches?(actual) ⇒ Boolean
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/model_context_protocol/rspec/matchers/be_valid_mcp_tool_response.rb', line 22 def matches?(actual) @actual = actual @failure_reasons = [] @serialized = serialize_response(actual) return false if @serialized.nil? validate_structure && validate_content && validate_is_error_flag end |