Class: Matchi::Change::From

Inherits:
Object
  • Object
show all
Defined in:
lib/matchi/change/from.rb,
lib/matchi/change/from/to.rb

Overview

*Change from to* wrapper.

Defined Under Namespace

Classes: To

Instance Method Summary collapse

Constructor Details

#initialize(expected, &state) ⇒ From

Initialize the wrapper with an object and a block.

Examples:

require "matchi/change/from"

object = "foo"

Matchi::Change::From.new("foo") { object.to_s }

Parameters:

  • expected (#object_id)

    An expected initial value.

  • state (Proc)

    A block of code to execute to get the state of the object.



21
22
23
24
# File 'lib/matchi/change/from.rb', line 21

def initialize(expected, &state)
  @expected = expected
  @state    = state
end

Instance Method Details

#to(expected_new_value) ⇒ #matches?

Specifies the new value to expect.

Examples:

require "matchi/change/from"

object = "foo"

change_from_wrapper = Matchi::Change::From.new("foo") { object.to_s }
change_from_wrapper.to("FOO")

Parameters:

  • expected_new_value (#object_id)

    The new value to expect.

Returns:

  • (#matches?)

    A *change from to* matcher.



39
40
41
# File 'lib/matchi/change/from.rb', line 39

def to(expected_new_value)
  To.new(@expected, expected_new_value, &@state)
end