Sha256: d166a4b931f11b1cc92a422bd1e22fdf81b0d6f9311ee1397d1981bf2d7df691

Contents?: true

Size: 606 Bytes

Versions: 2

Compression:

Stored size: 606 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
    #
    # @see Matcher#pass?
    def to(definition)
      Matcher.pass?(definition, &@actual)
    end

    # Evaluate to a negative assertion.
    #
    # @api public
    #
    # @see Matcher#pass?
    def not_to(definition)
      to(definition).equal?(false)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
expect-0.0.5 lib/expect/expectation_target.rb
expect-0.0.4 lib/expect/expectation_target.rb