class RSpec::Expectations::ExpectationTarget
directly by users. Use ‘expect` instead.
@note `ExpectationTarget` is not intended to be instantiated
expect(actual).not_to eq(3)
# with `not_to`
expect(actual).to eq(3)
# used with `to`
expect { do_something } # => ExpectationTarget wrapping the block
expect(something) # => ExpectationTarget wrapping something
@example
Wraps the target of an expectation.
def self.for(value, block)
- Private: -
def self.for(value, block) if UndefinedValue.equal?(value) unless block raise ArgumentError, "You must pass either an argument or a block to `expect`." end BlockExpectationTarget.new(block) elsif block raise ArgumentError, "You cannot pass both an argument and a block to `expect`." else ValueExpectationTarget.new(value) end end
def initialize(value)
- Api: - private
def initialize(value) @target = value end