sidekiq-amigo 1.13.0 → 1.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/amigo/spec_helpers.rb +30 -10
- data/lib/amigo/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c75430ea4c493cfee46c6de0daf1e64b8a6bea0e17017524dc2bc540bf7f30b2
|
4
|
+
data.tar.gz: 3bd32447b4f3d52f3512570bb3af6d5cab2643619bc83c9e95c17c0fa66418a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6fa8f511ead61d4a89473fdf3eef6ed58299219e98d8172098beddbda6b73ba19822c777536f924986940bac0787382b3752f1fd921405793f14dc8307ce9897
|
7
|
+
data.tar.gz: ca0f43716e1067f606956d14b3db8457115e57d1732c181d0006491c979b440058c8d256e3d0da5f242c99409d14392169d3d78717c6544dc8423cf3bfe94cf2
|
data/lib/amigo/spec_helpers.rb
CHANGED
@@ -72,7 +72,7 @@ module Amigo
|
|
72
72
|
true
|
73
73
|
end
|
74
74
|
|
75
|
-
def matches?(given_proc)
|
75
|
+
def matches?(given_proc, negative_expectation=false)
|
76
76
|
unless given_proc.respond_to?(:call)
|
77
77
|
warn "publish matcher used with non-proc object #{given_proc.inspect}"
|
78
78
|
return false
|
@@ -88,24 +88,41 @@ module Amigo
|
|
88
88
|
given_proc.call
|
89
89
|
end
|
90
90
|
|
91
|
-
self.match_expected_events
|
91
|
+
self.match_expected_events(negative_expectation)
|
92
92
|
|
93
93
|
return @error.nil? && @missing.empty?
|
94
94
|
end
|
95
95
|
|
96
|
+
# rubocop:disable Naming/PredicatePrefix
|
97
|
+
def does_not_match?(given_proc)
|
98
|
+
!matches?(given_proc, true)
|
99
|
+
end
|
100
|
+
# rubocop:enable Naming/PredicatePrefix
|
101
|
+
|
96
102
|
def on_publish_error(err)
|
97
103
|
@error = err
|
98
104
|
end
|
99
105
|
|
100
|
-
def match_expected_events
|
106
|
+
def match_expected_events(negative_expectation)
|
101
107
|
@expected_events.each do |expected_event, expected_payload|
|
108
|
+
if expected_event.nil? && !negative_expectation
|
109
|
+
RSpec::Expectations.configuration.false_positives_handler.call(
|
110
|
+
"Using the `publish` matcher without providing a specific " \
|
111
|
+
"event name risks false positives, since `publish` " \
|
112
|
+
"will match any event. Instead, provide the name " \
|
113
|
+
"of the event you are matching against."\
|
114
|
+
"This message can be suppressed by setting: " \
|
115
|
+
"`RSpec::Expectations.configuration.on_potential_false" \
|
116
|
+
"_positives = :nothing`",
|
117
|
+
)
|
118
|
+
end
|
102
119
|
match = @recorded_events.find do |recorded|
|
103
120
|
self.event_names_match?(expected_event, recorded.name) &&
|
104
121
|
self.payloads_match?(expected_payload, recorded.payload)
|
105
122
|
end
|
106
123
|
|
107
124
|
if match
|
108
|
-
self.add_matched(expected_event, expected_payload)
|
125
|
+
self.add_matched(expected_event, expected_payload, match)
|
109
126
|
else
|
110
127
|
self.add_missing(expected_event, expected_payload)
|
111
128
|
end
|
@@ -113,6 +130,7 @@ module Amigo
|
|
113
130
|
end
|
114
131
|
|
115
132
|
def event_names_match?(expected, actual)
|
133
|
+
return true if expected.nil?
|
116
134
|
return expected.matches?(actual) if expected.respond_to?(:matches?)
|
117
135
|
return expected.match?(actual) if expected.respond_to?(:match?)
|
118
136
|
return expected == actual
|
@@ -123,8 +141,8 @@ module Amigo
|
|
123
141
|
return expected.nil? || expected.empty? || expected == actual
|
124
142
|
end
|
125
143
|
|
126
|
-
def add_matched(
|
127
|
-
@matched << [
|
144
|
+
def add_matched(topic, payload, event)
|
145
|
+
@matched << [topic, payload, event]
|
128
146
|
end
|
129
147
|
|
130
148
|
def add_missing(event, payload)
|
@@ -156,10 +174,12 @@ module Amigo
|
|
156
174
|
|
157
175
|
def failure_message_when_negated
|
158
176
|
messages = []
|
159
|
-
@matched.each do |
|
160
|
-
message = "expected a '
|
161
|
-
message <<
|
162
|
-
message << " but one was
|
177
|
+
@matched.each do |topic, payload, event|
|
178
|
+
message = "expected a '#{topic || event.name}' event not to be fired"
|
179
|
+
message << " with a payload of #{payload.inspect}" if payload
|
180
|
+
message << " but one was"
|
181
|
+
event.payload.any? && message << ": #{event.payload.inspect}"
|
182
|
+
message << "."
|
163
183
|
messages << message
|
164
184
|
end
|
165
185
|
|
data/lib/amigo/version.rb
CHANGED