Sha256: 39ed4d5bb5c6bdd1bb1d1487b4f7ee6e74dc838ad1814a71281af9f330a43817

Contents?: true

Size: 887 Bytes

Versions: 2

Compression:

Stored size: 887 Bytes

Contents

require_relative File.join '..', 'sandbox'

module Spectus
  # Contains requirement levels.
  #
  module RequirementLevel
    # _High_ requirement level.
    #
    class High < BasicObject
      # Initialize the requirement level class.
      #
      # @param [Hash] definition
      # @param [Boolean] negate
      def initialize(definition, negate = false)
        @definition = definition
        @negate     = negate
      end

      # Evaluate the expectation with the passed block.
      #
      # @return [Boolean] report if the expectation is true or false.
      def pass?(&actual)
        sandbox(&actual).pass?(@negate)
      end

      protected

      # Run the actual block against the definition.
      #
      # @return [Boolean] report if the expectation is true or false.
      def sandbox(&actual)
        Sandbox.new(@definition, &actual)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spectus-2.0.1 lib/spectus/requirement_level/high.rb
spectus-2.0.0 lib/spectus/requirement_level/high.rb