lib/rspec/matchers/built_in/change.rb in rspec-expectations-3.10.2 vs lib/rspec/matchers/built_in/change.rb in rspec-expectations-3.11.0
- old
+ new
@@ -75,10 +75,15 @@
# @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
@@ -156,10 +161,15 @@
# @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}"
@@ -199,10 +209,15 @@
# @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|
@@ -335,10 +350,12 @@
# Instead, matchers must pass a block to `perform_change`, which yields
# the `actual_before` value before applying the change.
class ChangeDetails
attr_reader :actual_after
+ UNDEFINED = Module.new.freeze
+
def initialize(matcher_name, receiver=nil, message=nil, &block)
if receiver && !message
raise(
ArgumentError,
"`change` requires either an object and message " \
@@ -349,9 +366,14 @@
@matcher_name = matcher_name
@receiver = receiver
@message = message
@value_proc = block
+ # TODO: temporary measure to mute warning of access to an initialized
+ # instance variable when a deprecated implicit block expectation
+ # syntax is used. This may be removed once `fail` is used, and the
+ # matcher never issues this warning.
+ @actual_after = UNDEFINED
end
def value_representation
@value_representation ||=
if @message