Class: RSpec::Expectations::ExpectationTarget
- Includes:
- InstanceMethods
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-expectations-3.12.2/lib/rspec/expectations/expectation_target.rb
Overview
‘ExpectationTarget` is not intended to be instantiated directly by users. Use `expect` instead.
Wraps the target of an expectation.
Direct Known Subclasses
Defined Under Namespace
Modules: InstanceMethods
Constant Summary collapse
- UndefinedValue =
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 because `nil` is a valid value to pass.
Module.new
Instance Attribute Summary collapse
-
#target ⇒ Object
readonly
The target of the expectation.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(value) ⇒ ExpectationTarget
constructor
private
A new instance of ExpectationTarget.
Methods included from InstanceMethods
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/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-expectations-3.12.2/lib/rspec/expectations/expectation_target.rb', line 31 def initialize(value) @target = value end |
Instance Attribute Details
#target ⇒ Object (readonly)
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.
28 29 30 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-expectations-3.12.2/lib/rspec/expectations/expectation_target.rb', line 28 def target @target end |
Class Method Details
.for(value, block) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-expectations-3.12.2/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 |