Class: RSpec::Expectations::ExpectationTarget
Relationships & Source Files | |
Namespace Children | |
Modules:
| |
Extension / Inclusion / Inheritance Descendants | |
Subclasses:
RSpec::Expectations::BlockExpectationTarget, RSpec::Expectations::ValueExpectationTarget
|
|
Super Chains via Extension / Inclusion / Inheritance | |
Instance Chain:
self,
InstanceMethods
|
|
Inherits: | Object |
Defined in: | rspec-expectations/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.
Constant Summary
-
UndefinedValue =
Internal use only
Used as a sentinel value to be able to tell when the user did not pass an argument. We can’t use
nil
for that becausenil
is a valid value to pass.Module.new
Class Method Summary
- .for(value, block) Internal use only Internal use only
- .new(value) ⇒ ExpectationTarget constructor Internal use only Internal use only
Instance Attribute Summary
- #target ⇒ Object readonly
Instance Method Summary
InstanceMethods
- Included
#not_to | Runs the given expectation, passing if |
#to | Runs the given expectation, passing if |
#to_not | Alias for InstanceMethods#not_to. |
#prevent_operator_matchers |
Class Method Details
.for(value, block)
This method is for internal use only.
[ GitHub ]
# File 'rspec-expectations/lib/rspec/expectations/expectation_target.rb', line 36
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
Instance Attribute Details
#target ⇒ Object
(readonly)
Note:
this name aligns with Minitest::Expectation
so that our ExpectationTarget::InstanceMethods
module can be included in that class when used in a Minitest context.
# File 'rspec-expectations/lib/rspec/expectations/expectation_target.rb', line 28
attr_reader :target