Class: ModelContextProtocol::RSpec::Matchers::HaveMessageCount
- Inherits:
-
Object
- Object
- ModelContextProtocol::RSpec::Matchers::HaveMessageCount
- Defined in:
- lib/model_context_protocol/rspec/matchers/have_message_count.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(expected_count) ⇒ HaveMessageCount
constructor
A new instance of HaveMessageCount.
- #matches?(actual) ⇒ Boolean
Constructor Details
#initialize(expected_count) ⇒ HaveMessageCount
16 17 18 19 |
# File 'lib/model_context_protocol/rspec/matchers/have_message_count.rb', line 16 def initialize(expected_count) @expected_count = expected_count @failure_reasons = [] end |
Instance Method Details
#description ⇒ Object
41 42 43 |
# File 'lib/model_context_protocol/rspec/matchers/have_message_count.rb', line 41 def description "have #{@expected_count} message(s)" end |
#failure_message ⇒ Object
32 33 34 35 |
# File 'lib/model_context_protocol/rspec/matchers/have_message_count.rb', line 32 def "expected response to have #{@expected_count} message(s), but:\n" + @failure_reasons.map { |reason| " - #{reason}" }.join("\n") end |
#failure_message_when_negated ⇒ Object
37 38 39 |
# File 'lib/model_context_protocol/rspec/matchers/have_message_count.rb', line 37 def "expected response not to have #{@expected_count} message(s), but it did" end |
#matches?(actual) ⇒ Boolean
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/model_context_protocol/rspec/matchers/have_message_count.rb', line 21 def matches?(actual) @actual = actual @failure_reasons = [] @serialized = serialize_response(actual) return false if @serialized.nil? && validate_count end |