Sha256: 805e1829ad3b731e0f0c3f1f455d8b324f5b71123bd5f78043fe53c8230560bb

Contents?: true

Size: 780 Bytes

Versions: 1

Compression:

Stored size: 780 Bytes

Contents

require_relative 'matcher'

module Expect
  # Wraps the target of an expectation.
  #
  # @example
  #   this { stuff } # => ExpectationTarget wrapping the block
  class ExpectationTarget < BasicObject
    def initialize(&actual)
      @actual = actual
    end

    # Evaluate to a positive assertion.
    #
    # @api public
    #
    # @param [Hash, Symbol] definition
    #
    # @return [Boolean] report if the expectation is true or false
    def to(definition)
      Matcher.pass?(definition, &@actual)
    end

    # Evaluate to a negative assertion.
    #
    # @api public
    #
    # @param [Hash, Symbol] definition
    #
    # @return [Boolean] report if the expectation is true or false
    def not_to(definition)
      to(definition).equal?(false)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
expect-0.0.6 lib/expect/expectation_target.rb