Class: ModelContextProtocol::RSpec::Matchers::HaveResourceLinkContent

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

Instance Method Summary collapse

Constructor Details

#initialize(uri: nil, name: nil) ⇒ HaveResourceLinkContent



25
26
27
28
29
# File 'lib/model_context_protocol/rspec/matchers/have_resource_link_content.rb', line 25

def initialize(uri: nil, name: nil)
  @expected_uri = uri
  @expected_name = name
  @failure_reasons = []
end

Instance Method Details

#descriptionObject



53
54
55
56
# File 'lib/model_context_protocol/rspec/matchers/have_resource_link_content.rb', line 53

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

#failure_messageObject



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

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

#failure_message_when_negatedObject



48
49
50
51
# File 'lib/model_context_protocol/rspec/matchers/have_resource_link_content.rb', line 48

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

#matches?(actual) ⇒ Boolean



31
32
33
34
35
36
37
38
39
40
# File 'lib/model_context_protocol/rspec/matchers/have_resource_link_content.rb', line 31

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

  return false if @serialized.nil?

  validate_has_content &&
    validate_has_resource_link_content
end