class Expect::ExpectationTarget
Wraps the target of an expectation. This class is responsible for reporting if the expectation is true or false.
@example
ExpectationTarget.new { 42 }.to Equal: 42 # => true
Attributes
actual[R]
@return [BasicObject] the object to be compared with the expected one
though the matcher.
Public Class Methods
new(&actual)
click to toggle source
Create a new expection target
@example
new { 42 }.to Equal: 42 # => true
@param actual [Proc] the value which is compared with the expected value.
# File lib/expect/expectation_target.rb, line 16 def initialize(&actual) @actual = actual end
Public Instance Methods
not_to(definition)
click to toggle source
to(definition)
click to toggle source
Evaluate to a positive assertion.
@param definition [Array, Hash, Symbol] The definition of the expected
value.
@return [Boolean] report if the expectation is true or false
# File lib/expect/expectation_target.rb, line 31 def to(definition) matcher(definition).matches?(&actual) end
Private Instance Methods
matcher(definition)
click to toggle source
@api private
Load the matcher.
@param (see to
)
@return [#matches?] the matcher
# File lib/expect/expectation_target.rb, line 53 def matcher(definition) params = Array(definition).flatten(1) Matchi.fetch(params.first, *params[1..-1]) end