Class: ModelContextProtocol::RSpec::Matchers::HaveResourceBlob
- Inherits:
-
Object
- Object
- ModelContextProtocol::RSpec::Matchers::HaveResourceBlob
- Defined in:
- lib/model_context_protocol/rspec/matchers/have_resource_blob.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(expected_blob = nil) ⇒ HaveResourceBlob
constructor
A new instance of HaveResourceBlob.
- #matches?(actual) ⇒ Boolean
Constructor Details
#initialize(expected_blob = nil) ⇒ HaveResourceBlob
Returns a new instance of HaveResourceBlob.
19 20 21 22 |
# File 'lib/model_context_protocol/rspec/matchers/have_resource_blob.rb', line 19 def initialize(expected_blob = nil) @expected_blob = expected_blob @failure_reasons = [] end |
Instance Method Details
#description ⇒ Object
46 47 48 49 |
# File 'lib/model_context_protocol/rspec/matchers/have_resource_blob.rb', line 46 def description constraint = @expected_blob ? " matching #{@expected_blob.inspect}" : "" "have resource blob content#{constraint}" end |
#failure_message ⇒ Object
35 36 37 38 39 |
# File 'lib/model_context_protocol/rspec/matchers/have_resource_blob.rb', line 35 def constraint = @expected_blob ? " matching #{@expected_blob.inspect}" : "" "expected resource response to have blob content#{constraint}, but:\n" + @failure_reasons.map { |reason| " - #{reason}" }.join("\n") end |
#failure_message_when_negated ⇒ Object
41 42 43 44 |
# File 'lib/model_context_protocol/rspec/matchers/have_resource_blob.rb', line 41 def constraint = @expected_blob ? " matching #{@expected_blob.inspect}" : "" "expected resource response not to have blob content#{constraint}, 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_resource_blob.rb', line 24 def matches?(actual) @actual = actual @failure_reasons = [] @serialized = serialize_response(actual) return false if @serialized.nil? validate_has_contents && validate_has_blob end |