Class: ModelContextProtocol::RSpec::Matchers::BeMcpErrorResponse
- Inherits:
-
Object
- Object
- ModelContextProtocol::RSpec::Matchers::BeMcpErrorResponse
- Defined in:
- lib/model_context_protocol/rspec/matchers/be_mcp_error_response.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(expected_message = nil) ⇒ BeMcpErrorResponse
constructor
A new instance of BeMcpErrorResponse.
- #matches?(actual) ⇒ Boolean
Constructor Details
#initialize(expected_message = nil) ⇒ BeMcpErrorResponse
Returns a new instance of BeMcpErrorResponse.
22 23 24 25 |
# File 'lib/model_context_protocol/rspec/matchers/be_mcp_error_response.rb', line 22 def initialize( = nil) = @failure_reasons = [] end |
Instance Method Details
#description ⇒ Object
49 50 51 52 |
# File 'lib/model_context_protocol/rspec/matchers/be_mcp_error_response.rb', line 49 def description constraint = ? " with message matching #{@expected_message.inspect}" : "" "be an MCP error response#{constraint}" end |
#failure_message ⇒ Object
38 39 40 41 42 |
# File 'lib/model_context_protocol/rspec/matchers/be_mcp_error_response.rb', line 38 def constraint = ? " with message matching #{@expected_message.inspect}" : "" "expected response to be an MCP error response#{constraint}, but:\n" + @failure_reasons.map { |reason| " - #{reason}" }.join("\n") end |
#failure_message_when_negated ⇒ Object
44 45 46 47 |
# File 'lib/model_context_protocol/rspec/matchers/be_mcp_error_response.rb', line 44 def constraint = ? " with message matching #{@expected_message.inspect}" : "" "expected response not to be an MCP error response#{constraint}, but it was" end |
#matches?(actual) ⇒ Boolean
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/model_context_protocol/rspec/matchers/be_mcp_error_response.rb', line 27 def matches?(actual) @actual = actual @failure_reasons = [] @serialized = serialize_response(actual) return false if @serialized.nil? validate_is_error && end |