Class: ModelContextProtocol::RSpec::Matchers::HaveEmbeddedResourceContent

Inherits:
Object
  • Object
show all
Defined in:
lib/model_context_protocol/rspec/matchers/have_embedded_resource_content.rb

Instance Method Summary collapse

Constructor Details

#initialize(uri: nil, mime_type: nil) ⇒ HaveEmbeddedResourceContent

Returns a new instance of HaveEmbeddedResourceContent.



19
20
21
22
23
# File 'lib/model_context_protocol/rspec/matchers/have_embedded_resource_content.rb', line 19

def initialize(uri: nil, mime_type: nil)
  @expected_uri = uri
  @expected_mime_type = mime_type
  @failure_reasons = []
end

Instance Method Details

#descriptionObject



47
48
49
50
# File 'lib/model_context_protocol/rspec/matchers/have_embedded_resource_content.rb', line 47

def description
  constraints = build_constraint_message
  "have embedded resource content#{constraints}"
end

#failure_messageObject



36
37
38
39
40
# File 'lib/model_context_protocol/rspec/matchers/have_embedded_resource_content.rb', line 36

def failure_message
  constraints = build_constraint_message
  "expected response to have embedded resource content#{constraints}, but:\n" +
    @failure_reasons.map { |reason| "  - #{reason}" }.join("\n")
end

#failure_message_when_negatedObject



42
43
44
45
# File 'lib/model_context_protocol/rspec/matchers/have_embedded_resource_content.rb', line 42

def failure_message_when_negated
  constraints = build_constraint_message
  "expected response not to have embedded resource content#{constraints}, but it did"
end

#matches?(actual) ⇒ Boolean

Returns:



25
26
27
28
29
30
31
32
33
34
# File 'lib/model_context_protocol/rspec/matchers/have_embedded_resource_content.rb', line 25

def matches?(actual)
  @actual = actual
  @failure_reasons = []
  @serialized = serialize_response(actual)

  return false if @serialized.nil?

  validate_has_content &&
    validate_has_embedded_resource_content
end