Sha256: 781197b0c7b98c20970eddc89074a7f7209d248ce071733bf32a07f4b57b602e
Contents?: true
Size: 1.96 KB
Versions: 4
Compression:
Stored size: 1.96 KB
Contents
# frozen_string_literal: true module Spectus # Namespace for the requirement levels. module RequirementLevel # Requirement level's base class. class Base # Initialize the requirement level class. # # @param callable [#call] The callable object to test. # @param isolation [Boolean] Compute actual in isolation? # @param negate [Boolean] Positive or negative assertion? # @param matcher [#matches?] The matcher. def initialize(callable:, isolation:, negate:, matcher:) @negate = negate @matcher = matcher @exam = Exam.new( callable: callable, isolation: isolation, negate: negate, matcher: matcher ) end # @return [#Exam] The exam. attr_reader :exam # @return [#matches?] The matcher that performed a boolean comparison # between the actual value and the expected value. attr_reader :matcher # The result of the expectation. # # @raise [Spectus::Result::Fail] The expectation is `false`. # @return [Spectus::Result::Pass] The expectation is `true`. def call Result.call(pass?).with( actual: exam.actual, error: exam.exception, expected: matcher.expected, got: exam.got, negate: negate?, valid: exam.valid?, matcher: matcher.class.to_sym, level: level ) end protected # @return [Symbol] The requirement level. def level self.class.name.split("::").fetch(-1).upcase.to_sym end # @note The boolean comparison between the actual value and the expected # value can be evaluated to a negative assertion. # # @return [Boolean] Positive or negative assertion? def negate? @negate end end end end require_relative File.join("..", "exam") require_relative File.join("..", "result")
Version data entries
4 entries across 4 versions & 1 rubygems