Class: BrainzLab::Testing::AlertExpectation
- Inherits:
-
Object
- Object
- BrainzLab::Testing::AlertExpectation
- Defined in:
- lib/brainzlab/testing/helpers.rb
Overview
Fluent expectation builder for alerts
Instance Method Summary collapse
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(name, store) ⇒ AlertExpectation
constructor
A new instance of AlertExpectation.
-
#satisfied? ⇒ Boolean
(also: #matches?)
Check if the expectation is satisfied.
-
#with_message(message) ⇒ self
Specify expected message.
-
#with_severity(severity) ⇒ self
Specify expected severity.
Constructor Details
#initialize(name, store) ⇒ AlertExpectation
Returns a new instance of AlertExpectation.
600 601 602 603 604 605 |
# File 'lib/brainzlab/testing/helpers.rb', line 600 def initialize(name, store) @name = name.to_s @store = store @expected_message = nil @expected_severity = nil end |
Instance Method Details
#failure_message ⇒ Object
637 638 639 640 641 642 643 |
# File 'lib/brainzlab/testing/helpers.rb', line 637 def parts = ["expected alert '#{@name}'"] parts << "with message '#{@expected_message}'" if @expected_message parts << "with severity :#{@expected_severity}" if @expected_severity parts << " to be sent, but it wasn't" parts.join end |
#failure_message_when_negated ⇒ Object
645 646 647 |
# File 'lib/brainzlab/testing/helpers.rb', line 645 def "expected alert '#{@name}' not to be sent, but it was" end |
#satisfied? ⇒ Boolean Also known as: matches?
Check if the expectation is satisfied
631 632 633 |
# File 'lib/brainzlab/testing/helpers.rb', line 631 def satisfied? @store.alert_sent?(@name, message: @expected_message, severity: @expected_severity) end |
#with_message(message) ⇒ self
Specify expected message
612 613 614 615 |
# File 'lib/brainzlab/testing/helpers.rb', line 612 def () @expected_message = self end |
#with_severity(severity) ⇒ self
Specify expected severity
622 623 624 625 |
# File 'lib/brainzlab/testing/helpers.rb', line 622 def with_severity(severity) @expected_severity = severity self end |