Class: RSpec::Clone::ExpectationTarget::Base Private

Inherits:
Object
  • Object
show all
Defined in:
lib/r_spec/clone/expectation_target/base.rb

Overview

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

Note:

RSpec::Clone::ExpectationTarget::Base is not intended to be instantiated directly by users. Use expect instead.

Abstract expectation target base class.

Direct Known Subclasses

Block, Value

Instance Method Summary collapse

Constructor Details

#initialize(input) ⇒ Base

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.

Instantiate a new expectation target.



19
20
21
# File 'lib/r_spec/clone/expectation_target/base.rb', line 19

def initialize(input)
  @input = input
end

Instance Method Details

#not_to(matcher) ⇒ nil

Runs the given expectation, passing if matcher returns false.

Examples:

_Absolute prohibition_ definition

expect { "foo".size }.not_to be(4)

Raises:

  • (SystemExit)

    Terminate execution immediately by calling ‘Kernel.exit(false)` with a failure message written to STDERR.



49
50
51
# File 'lib/r_spec/clone/expectation_target/base.rb', line 49

def not_to(matcher)
  absolute_requirement(matcher:, negate: true)
end

#to(matcher) ⇒ nil

Runs the given expectation, passing if matcher returns true.

Examples:

_Absolute requirement_ definition

expect { "foo".upcase }.to eq("foo")

Raises:

  • (SystemExit)

    Terminate execution immediately by calling ‘Kernel.exit(false)` with a failure message written to STDERR.



34
35
36
# File 'lib/r_spec/clone/expectation_target/base.rb', line 34

def to(matcher)
  absolute_requirement(matcher:, negate: false)
end