lib/expect/expectation_target.rb in expect-0.0.10 vs lib/expect/expectation_target.rb in expect-0.0.11
- old
+ new
@@ -2,12 +2,10 @@
module Expect
# Wraps the target of an expectation. This class is responsible for reporting
# if the expectation is true or false.
#
- # @api private
- #
# @example
# ExpectationTarget.new { 42 }.to Equal: 42 # => true
class ExpectationTarget
# Create a new expection target
#
@@ -17,38 +15,40 @@
# @param actual [Proc] the value which is compared with the expected value.
def initialize(&actual)
@actual = actual
end
+ # @return [BasicObject] the object to be compared with the expected one
+ # though the matcher.
+ #
attr_reader :actual
# Evaluate to a positive assertion.
#
- # @api public
+ # @param definition [Array, Hash, Symbol] The definition of the expected
+ # value.
#
- # @param [Hash, Symbol] definition
- #
# @return [Boolean] report if the expectation is true or false
def to(definition)
matcher(definition).matches?(&actual)
end
# Evaluate to a negative assertion.
#
- # @api public
+ # @param (see #to)
#
- # @param [Hash, Symbol] definition
- #
- # @return [Boolean] report if the expectation is not true or not false
+ # @return (see #to)
def not_to(definition)
!to(definition)
end
private
+ # @api private
+ #
# Load the matcher.
#
- # @param [Array, Hash, Symbol] definition
+ # @param (see #to)
#
# @return [#matches?] the matcher
def matcher(definition)
params = Array(definition).flatten(1)
Matchi.fetch(params.first, *params[1..-1])