Sha256: 6a0c8bbcd9dca8954fa8c0bc86b20c2a3a250a2df992ce3b6ff041de495ebb80

Contents?: true

Size: 996 Bytes

Versions: 2

Compression:

Stored size: 996 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

    # Verify the expectation.
    #
    # @param spec [Proc] A spec to compare against the computed actual value.
    #
    # @return [::Spectus::Result::Pass, ::Spectus::Result::Fail] Pass or fail.
    def verify(&spec)
      instance_eval(&spec)
    rescue ::Spectus::Result::Fail => f
      f
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fix-0.17.1 lib/fix/it.rb
fix-0.17.0 lib/fix/it.rb