Sha256: b78245ccc4cbae32acbe9e64abf52ee360e5271212813fa89007a482d63c59ce

Contents?: true

Size: 943 Bytes

Versions: 1

Compression:

Stored size: 943 Bytes

Contents

require 'fix'

# Namespace for the Fix framework.
#
# @api public
#
module Fix
  # Open the on class.
  #
  # @api private
  #
  class On
    # Add its method to the DSL.
    #
    # @api public
    #
    # @example Its absolute value must equal 42
    #   its(:abs) { MUST Equal: 42 }
    #
    # @param method_name [Symbol] The identifier of a method.
    # @param spec        [Proc]   A spec to compare against the computed value.
    #
    # @return [Array] List of results.
    def its(method_name, &spec)
      challenges = @challenges + [Defi.send(method_name)]

      i = It.new(@front_object, challenges, @helpers.dup)

      result = begin
                 i.instance_eval(&spec)
               rescue Spectus::Result::Fail => f
                 f
               end

      if @configuration.fetch(:verbose, true)
        print result.to_char(@configuration.fetch(:color, false))
      end

      results << result
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fix-its-0.3.0 lib/fix/its.rb