Class: TeamsConnector::Matchers::HaveSentNotificationTo
- Inherits:
-
Object
- Object
- TeamsConnector::Matchers::HaveSentNotificationTo
show all
- Includes:
- RSpec::Matchers::Composable, ExpectedNumber, With
- Defined in:
- lib/teams_connector/matchers/have_sent_notification_to.rb
Defined Under Namespace
Classes: RelativityNotSupported
Instance Method Summary
collapse
Methods included from With
#with, #with_template
#at_least, #at_most, #exactly, #once, #thrice, #times, #twice
Constructor Details
Returns a new instance of HaveSentNotificationTo.
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/teams_connector/matchers/have_sent_notification_to.rb', line 15
def initialize(channel, template)
@filter = {
channel: channel,
template: template
}
@block = proc {}
@data = nil
@template_data = nil
set_expected_number(:exactly, 1)
end
|
Instance Method Details
#failure_message ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/teams_connector/matchers/have_sent_notification_to.rb', line 26
def failure_message
msg = "expected to send #{base_message}"
if @unmatching_ntfcts.any?
msg += "\nSent notifications"
msg += " to #{@filter[:channel]}" if @filter[:channel]
msg += " of #{@filter[:template]}" if @filter[:template]
msg += ':'
@unmatching_ntfcts.each { |data| msg += "\n #{data}" }
end
msg
end
|
#failure_message_when_negated ⇒ Object
39
40
41
|
# File 'lib/teams_connector/matchers/have_sent_notification_to.rb', line 39
def failure_message_when_negated
"expected not to send #{base_message}"
end
|
#matches?(expectation) ⇒ Boolean
43
44
45
46
47
48
49
|
# File 'lib/teams_connector/matchers/have_sent_notification_to.rb', line 43
def matches?(expectation)
matching_notifications = in_block_notifications(expectation).select do |msg|
@filter.map { |k, v| msg[k] == v unless v.nil? }.compact.all?
end
check(matching_notifications)
end
|
#supports_block_expectations? ⇒ Boolean
51
52
53
|
# File 'lib/teams_connector/matchers/have_sent_notification_to.rb', line 51
def supports_block_expectations?
true
end
|