Sha256: 4ffd88316fdf0f5a79be67b16cb803d408aaede2c35be529c4292d6e026a491c

Contents?: true

Size: 1.38 KB

Versions: 5

Compression:

Stored size: 1.38 KB

Contents

# frozen_string_literal: true

require_relative "base"

module RSpec
  module Clone
    module ExpectationTarget
      # Wraps the target of an expectation with a value.
      #
      # @example
      #   expect(something) # => ExpectationTarget::Value wrapping something
      #
      #   # used with `to`
      #   expect(actual).to be(42)
      #
      #   # with `not_to`
      #   expect(actual).not_to be(4)
      #
      # @note `RSpec::ExpectationTarget::Value` is not intended to be instantiated
      #   directly by users. Use `expect` instead.
      class Value < Base
        protected

        # @param matcher  [#matches?] The matcher.
        # @param negate   [Boolean]   The assertion is positive or negative.
        #
        # @return [nil] Write a message to STDOUT.
        #
        # @raise [SystemExit] Terminate execution immediately by calling
        #   `Kernel.exit(false)` with a failure message written to STDERR.
        def absolute_requirement(matcher:, negate:)
          experiment = ::TestTube.pass(
            @actual,
            matcher: matcher,
            negate:  negate
          )

          result(
            experiment.got.equal?(true),
            actual:  experiment.actual,
            error:   experiment.error,
            got:     experiment.got,
            matcher: matcher,
            negate:  negate
          )
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
r_spec-clone-1.2.1 lib/r_spec/clone/expectation_target/value.rb
r_spec-clone-1.2.0 lib/r_spec/clone/expectation_target/value.rb
r_spec-clone-1.1.0 lib/r_spec/clone/expectation_target/value.rb
r_spec-clone-1.0.2 lib/r_spec/clone/expectation_target/value.rb
r_spec-clone-1.0.0.rc1 lib/r_spec/clone/expectation_target/value.rb