lib/matchi/change/from/to.rb in matchi-3.0.0 vs lib/matchi/change/from/to.rb in matchi-3.1.0
- old
+ new
@@ -3,10 +3,13 @@
module Matchi
class Change
class From
# *Change from to* matcher.
class To
+ # @return [#object_id] An expected new value.
+ attr_reader :expected
+
# Initialize the matcher with two objects and a block.
#
# @example
# require "matchi/change/from/to"
#
@@ -31,33 +34,35 @@
# require "matchi/change/from/to"
#
# object = "foo"
#
# matcher = Matchi::Change::From::To.new("foo", "FOO") { object.to_s }
+ #
+ # matcher.expected # => "FOO"
# matcher.matches? { object.upcase! } # => true
#
# @yieldreturn [#object_id] The block of code to execute.
#
# @return [Boolean] Comparison between the value before and after the
# code execution.
- def matches?(*, **)
+ def matches?
value_before = @state.call
return false unless @expected_init == value_before
yield
value_after = @state.call
- @expected == value_after
+ expected == value_after
end
# A string containing a human-readable representation of the matcher.
def inspect
- "#{self.class}(#{@expected_init.inspect}, #{@expected.inspect})"
+ "#{self.class}(#{@expected_init.inspect}, #{expected.inspect})"
end
# Returns a string representing the matcher.
def to_s
- "change from #{@expected_init.inspect} to #{@expected.inspect}"
+ "change from #{@expected_init.inspect} to #{expected.inspect}"
end
end
end
end
end