Class: ModelContextProtocol::RSpec::Matchers::BeValidMcpResourceResponse
- Inherits:
-
Object
- Object
- ModelContextProtocol::RSpec::Matchers::BeValidMcpResourceResponse
- Defined in:
- lib/model_context_protocol/rspec/matchers/be_valid_mcp_resource_response.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize ⇒ BeValidMcpResourceResponse
constructor
A new instance of BeValidMcpResourceResponse.
- #matches?(actual) ⇒ Boolean
Constructor Details
#initialize ⇒ BeValidMcpResourceResponse
Returns a new instance of BeValidMcpResourceResponse.
16 17 18 |
# File 'lib/model_context_protocol/rspec/matchers/be_valid_mcp_resource_response.rb', line 16 def initialize @failure_reasons = [] end |
Instance Method Details
#description ⇒ Object
40 41 42 |
# File 'lib/model_context_protocol/rspec/matchers/be_valid_mcp_resource_response.rb', line 40 def description "be a valid MCP resource response" end |
#failure_message ⇒ Object
31 32 33 34 |
# File 'lib/model_context_protocol/rspec/matchers/be_valid_mcp_resource_response.rb', line 31 def "expected #{@actual.class} to be a valid MCP resource response, but:\n" + @failure_reasons.map { |reason| " - #{reason}" }.join("\n") end |
#failure_message_when_negated ⇒ Object
36 37 38 |
# File 'lib/model_context_protocol/rspec/matchers/be_valid_mcp_resource_response.rb', line 36 def "expected #{@actual.class} not to be a valid MCP resource response, but it was" end |
#matches?(actual) ⇒ Boolean
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/model_context_protocol/rspec/matchers/be_valid_mcp_resource_response.rb', line 20 def matches?(actual) @actual = actual @failure_reasons = [] @serialized = serialize_response(actual) return false if @serialized.nil? validate_structure && validate_contents end |