@@ -69,10 +69,10 @@ def description
6969
7070 def failure_message
7171 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 )
7474 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 } "
7676 end
7777 elsif @error_subscriber . events . empty?
7878 return 'Expected the block to report an error, but none was reported.'
@@ -94,13 +94,9 @@ def failure_message
9494
9595 def failure_message_when_negated
9696 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+
104100 "Expected the block not to report any errors, but #{ error_count } #{ error_word } #{ verb } been reported."
105101 end
106102
@@ -129,8 +125,8 @@ def attributes_match_if_specified?
129125 return true if @attributes . empty?
130126 return false if @error_subscriber . events . empty?
131127
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 )
134130 end
135131
136132 def actual_error
@@ -139,7 +135,7 @@ def actual_error
139135
140136 def attributes_match? ( actual )
141137 @attributes . all? do |key , value |
142- if defined? ( RSpec :: Matchers ) && value . respond_to? ( :matches? )
138+ if value . respond_to? ( :matches? )
143139 value . matches? ( actual [ key ] )
144140 else
145141 actual [ key ] == value
@@ -149,7 +145,7 @@ def attributes_match?(actual)
149145
150146 def unmatched_attributes ( actual )
151147 @attributes . reject do |key , value |
152- if defined? ( RSpec :: Matchers ) && value . respond_to? ( :matches? )
148+ if value . respond_to? ( :matches? )
153149 value . matches? ( actual [ key ] )
154150 else
155151 actual [ key ] == value
0 commit comments