Class: RSpec::Expectations::ExpectationTarget

Inherits:
Object
  • Object
show all
Includes:
InstanceMethods
Defined in:
lib/rspec/expectations/expectation_target.rb

Overview

Note:

ExpectationTarget is not intended to be instantiated directly by users. Use expect instead.

Wraps the target of an expectation.

Examples:

expect(something)       # => ExpectationTarget wrapping something
expect { do_something } # => ExpectationTarget wrapping the block

# used with `to`
expect(actual).to eq(3)
# with `not_to`
expect(actual).not_to eq(3)

Defined Under Namespace

Modules: InstanceMethods

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from InstanceMethods

#not_to, #to

Constructor Details

#initialize(value) ⇒ ExpectationTarget

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of ExpectationTarget.

31
32
33
# File 'lib/rspec/expectations/expectation_target.rb', line 31
def initialize(value)
  @target = value
end

Instance Attribute Details

#targetObject (readonly)

Note:

this name aligns with Minitest::Expectation so that our InstanceMethods module can be included in that class when used in a Minitest context.

Returns the target of the expectation.

Returns:

  • (Object)

    the target of the expectation

28
29
30
# File 'lib/rspec/expectations/expectation_target.rb', line 28
def target
  @target
end