Class: ModelContextProtocol::RSpec::Matchers::HaveStructuredContent
- Inherits:
-
Object
- Object
- ModelContextProtocol::RSpec::Matchers::HaveStructuredContent
- Defined in:
- lib/model_context_protocol/rspec/matchers/have_structured_content.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(expected_content) ⇒ HaveStructuredContent
constructor
A new instance of HaveStructuredContent.
- #matches?(actual) ⇒ Boolean
Constructor Details
#initialize(expected_content) ⇒ HaveStructuredContent
Returns a new instance of HaveStructuredContent.
19 20 21 22 |
# File 'lib/model_context_protocol/rspec/matchers/have_structured_content.rb', line 19 def initialize(expected_content) @expected_content = expected_content @failure_reasons = [] end |
Instance Method Details
#description ⇒ Object
44 45 46 |
# File 'lib/model_context_protocol/rspec/matchers/have_structured_content.rb', line 44 def description "have structured content matching #{@expected_content.inspect}" end |
#failure_message ⇒ Object
35 36 37 38 |
# File 'lib/model_context_protocol/rspec/matchers/have_structured_content.rb', line 35 def "expected response to have structured content matching #{@expected_content.inspect}, but:\n" + @failure_reasons.map { |reason| " - #{reason}" }.join("\n") end |
#failure_message_when_negated ⇒ Object
40 41 42 |
# File 'lib/model_context_protocol/rspec/matchers/have_structured_content.rb', line 40 def "expected response not to have structured content matching #{@expected_content.inspect}, but it did" end |
#matches?(actual) ⇒ Boolean
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/model_context_protocol/rspec/matchers/have_structured_content.rb', line 24 def matches?(actual) @actual = actual @failure_reasons = [] @serialized = serialize_response(actual) return false if @serialized.nil? validate_has_structured_content && validate_content_matches end |