@@ -69,10 +69,10 @@ def description
69
69
70
70
def failure_message
71
71
if !@error_subscriber . events . empty? && !@attributes . empty?
72
- event_data = @error_subscriber . events . last [ 1 ] . with_indifferent_access
73
- unmatched = unmatched_attributes ( event_data [ "context" ] )
72
+ event_context = @error_subscriber . events . last [ 1 ] . with_indifferent_access [ "context" ]
73
+ unmatched = unmatched_attributes ( event_context )
74
74
unless unmatched . empty?
75
- return "Expected error attributes to match #{ @attributes } , but got these mismatches: #{ unmatched } and actual values are #{ event_data } "
75
+ return "Expected error attributes to match #{ @attributes } , but got these mismatches: #{ unmatched } and actual values are #{ event_context } "
76
76
end
77
77
elsif @error_subscriber . events . empty?
78
78
return 'Expected the block to report an error, but none was reported.'
@@ -94,13 +94,9 @@ def failure_message
94
94
95
95
def failure_message_when_negated
96
96
error_count = @error_subscriber . events . count
97
- if defined? ( ActiveSupport ::Inflector )
98
- error_word = 'error' . pluralize ( error_count )
99
- verb = error_count == 1 ? 'has' : 'have'
100
- else
101
- error_word = error_count == 1 ? 'error' : 'errors'
102
- verb = error_count == 1 ? 'has' : 'have'
103
- end
97
+ error_word = 'error' . pluralize ( error_count )
98
+ verb = error_count == 1 ? 'has' : 'have'
99
+
104
100
"Expected the block not to report any errors, but #{ error_count } #{ error_word } #{ verb } been reported."
105
101
end
106
102
@@ -129,8 +125,8 @@ def attributes_match_if_specified?
129
125
return true if @attributes . empty?
130
126
return false if @error_subscriber . events . empty?
131
127
132
- event_data = @error_subscriber . events . last [ 1 ] . with_indifferent_access
133
- attributes_match? ( event_data [ "context" ] )
128
+ event_context = @error_subscriber . events . last [ 1 ] . with_indifferent_access [ "context" ]
129
+ attributes_match? ( event_context )
134
130
end
135
131
136
132
def actual_error
@@ -139,7 +135,7 @@ def actual_error
139
135
140
136
def attributes_match? ( actual )
141
137
@attributes . all? do |key , value |
142
- if defined? ( RSpec :: Matchers ) && value . respond_to? ( :matches? )
138
+ if value . respond_to? ( :matches? )
143
139
value . matches? ( actual [ key ] )
144
140
else
145
141
actual [ key ] == value
@@ -149,7 +145,7 @@ def attributes_match?(actual)
149
145
150
146
def unmatched_attributes ( actual )
151
147
@attributes . reject do |key , value |
152
- if defined? ( RSpec :: Matchers ) && value . respond_to? ( :matches? )
148
+ if value . respond_to? ( :matches? )
153
149
value . matches? ( actual [ key ] )
154
150
else
155
151
actual [ key ] == value
0 commit comments