Sha256: 12ad6f8d3abde847c18f366429883ed9f324b633ca3facd64508f50a52b03c86

Contents?: true

Size: 1020 Bytes

Versions: 1

Compression:

Stored size: 1020 Bytes

Contents

require 'spectus/expectation_target'
require 'spectus/matchers'

module Fix
  # Wraps the target of an expectation.
  #
  # @api private
  #
  class It < Spectus::ExpectationTarget
    include ::Spectus::Matchers

    # Create a new expection target
    #
    # @param subject    [BasicObject] The front object.
    # @param challenges [Array]       The list of challenges.
    # @param helpers    [Hash]        The list of helpers.
    def initialize(subject, challenges, helpers)
      @subject    = subject
      @challenges = challenges
      @helpers    = helpers
    end

    # @!attribute [r] helpers
    #
    # @return [Hash] The list of helpers.
    attr_reader :helpers

    private

    # Override Ruby's method_missing in order to provide `On#let` interface.
    #
    # @api private
    #
    # @since 0.11.0
    #
    # @raise [NoMethodError] If doesn't respond to the given method.
    def method_missing(name, *args, &block)
      helpers.key?(name) ? helpers.fetch(name).call : super
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fix-0.16.0 lib/fix/it.rb