Sha256: a83d316c28585aef435c9511107b4dd68939ff672d5ddce2acbfa03700ade475

Contents?: true

Size: 661 Bytes

Versions: 4

Compression:

Stored size: 661 Bytes

Contents

# frozen_string_literal: true

require 'spectus/expectation_target'
require 'matchi/helper'

module Fix
  # Wraps the target of an expectation.
  class It < ::Spectus::ExpectationTarget
    include ::Matchi::Helper

    # Create a new expection target
    #
    # @param callable [#call] The object to test.
    def initialize(callable, **lets)
      raise unless callable.respond_to?(:call)

      @callable = callable
      @lets     = lets
    end

    private

    def method_missing(name, *args, &block)
      @lets.fetch(name) { super }
    end

    def respond_to_missing?(name, include_private = false)
      @lets.key?(name) || super
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fix-1.0.0.beta4 lib/fix/it.rb
fix-1.0.0.beta3 lib/fix/it.rb
fix-1.0.0.beta2 lib/fix/it.rb
fix-1.0.0.beta1 lib/fix/it.rb