Sha256: a9626497985471bae7386255f5a4dc0c5324338dbec60da67abb11698e4fea05
Contents?: true
Size: 1.28 KB
Versions: 1
Compression:
Stored size: 1.28 KB
Contents
require_relative File.join 'exception', 'failure' require_relative 'matcher' module Expect # Wraps the target of an expectation. # # @api private # # @example # ExpectationTarget.new { 42 }.to Equal: 42 # => true class ExpectationTarget # Create a new expection target # # @example # ExpectationTarget.new { block of code } # # @yieldparam actual the value which is compared with the expected value. def initialize(&actual) @actual = actual end # Evaluate to a positive assertion. # # @api public # # @param [Hash, Symbol] definition # # @return [Boolean] pass or fail the spec def to(definition) match?(definition) || fail(Failure) end # Evaluate to a negative assertion. # # @api public # # @param [Hash, Symbol] definition # # @return [Boolean] pass or fail the spec def not_to(definition) match?(definition).equal?(false) || fail(Failure) end private # Boolean comparison between the actual value and the expected value. # # @api private # # @param [Hash, Symbol] definition # # @return [Boolean] report if the expectation is true or false def match?(definition) Matcher.pass?(definition, &@actual) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
expect-0.0.9 | lib/expect/expectation_target.rb |