Sha256: fe63b876c34abbb610147fbb43b3392454bc422be73d9db175d0e2b47b9fe61d

Contents?: true

Size: 889 Bytes

Versions: 2

Compression:

Stored size: 889 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 [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, &spec)
      i = It.new(front_object, (challenges + [Defi.send(method)]), 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

2 entries across 2 versions & 1 rubygems

Version Path
fix-its-0.3.2 lib/fix/its.rb
fix-its-0.3.1 lib/fix/its.rb