Sha256: f8cb1748d18ba3fe29de2e34a56a2441b8c0bc7172bb0010d294794039649573
Contents?: true
Size: 1.96 KB
Versions: 1
Compression:
Stored size: 1.96 KB
Contents
# frozen_string_literal: true require_relative File.join("..", "exam") require_relative File.join("..", "result") 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 failed. # @return [Spectus::Result::Pass] The expectation passed. 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
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
spectus-3.3.4 | lib/spectus/requirement_level/base.rb |