lib/rspec/matchers/built_in/change.rb in rspec-expectations-3.8.5 vs lib/rspec/matchers/built_in/change.rb in rspec-expectations-3.8.6
- old
+ new
@@ -75,15 +75,10 @@
# @private
def supports_block_expectations?
true
end
- # @private
- def supports_value_expectations?
- false
- end
-
private
def initialize(receiver=nil, message=nil, &block)
@receiver = receiver
@message = message
@@ -110,14 +105,16 @@
raise SyntaxError, "Block not received by the `change` matcher. " \
"Perhaps you want to use `{ ... }` instead of do/end?"
end
def positive_failure_reason
+ return "was not given a block" unless Proc === @event_proc
"is still #{@actual_before_description}"
end
def negative_failure_reason
+ return "was not given a block" unless Proc === @event_proc
"did change from #{@actual_before_description} " \
"to #{description_of change_details.actual_after}"
end
end
@@ -159,18 +156,14 @@
# @private
def supports_block_expectations?
true
end
- # @private
- def supports_value_expectations?
- false
- end
-
private
def failure_reason
+ return "was not given a block" unless Proc === @event_proc
"was changed by #{description_of @change_details.actual_delta}"
end
end
# @api private
@@ -195,25 +188,21 @@
"change #{@change_details.value_representation} #{change_description}"
end
# @private
def failure_message
+ return not_given_a_block_failure unless Proc === @event_proc
return before_value_failure unless @matches_before
return did_not_change_failure unless @change_details.changed?
after_value_failure
end
# @private
def supports_block_expectations?
true
end
- # @private
- def supports_value_expectations?
- false
- end
-
private
def perform_change(event_proc)
@event_proc = event_proc
@change_details.perform_change(event_proc) do |actual_before|
@@ -251,10 +240,15 @@
def did_change_failure
"expected #{@change_details.value_representation} not to have changed, but " \
"did change from #{@actual_before_description} " \
"to #{description_of @change_details.actual_after}"
end
+
+ def not_given_a_block_failure
+ "expected #{@change_details.value_representation} to have changed " \
+ "#{change_description}, but was not given a block"
+ end
end
# @api private
# Used to specify a change from a specific value
# (and, optionally, to a specific value).
@@ -282,9 +276,10 @@
perform_change(event_proc) && !@change_details.changed? && @matches_before
end
# @private
def failure_message_when_negated
+ return not_given_a_block_failure unless Proc === @event_proc
return before_value_failure unless @matches_before
did_change_failure
end
private