class Spectus::Requirement::Base
Requirement
level's base class.
Public Class Methods
Initialize the requirement level class.
@param isolate [Boolean] Compute actual in a subprocess. @param matcher [#matches?] The matcher. @param negate [Boolean] Invert the matcher or not.
# File lib/spectus/requirement/base.rb, line 16 def initialize(isolate:, matcher:, negate:) @isolate = isolate @matcher = matcher @negate = negate end
Public Instance Methods
Test result.
@raise [::Expresenter::Fail] A failed spec exception. @return [::Expresenter::Pass] A passed spec instance.
@see github.com/fixrb/expresenter
@api public
# File lib/spectus/requirement/base.rb, line 30 def call(&block) test = ::TestTube.invoke(isolate: @isolate, matcher: @matcher, negate: @negate, &block) ::Expresenter.call(passed?(test)).with( actual: test.actual, definition: @matcher.to_s, error: test.error, expected: @matcher.expected, got: test.got, level: self.class.level, negate: @negate ) end
A string containing a human-readable representation of the definition.
@example The human-readable representation of an absolute requirement.
require "spectus" require "matchi/be" definition = Spectus.must Matchi::Be.new(1) definition.inspect # => "#<MUST Matchi::Be(1) isolate=false negate=false>"
@return [String] The human-readable representation of the definition.
@api public
# File lib/spectus/requirement/base.rb, line 59 def inspect "#<#{self.class.level} #{@matcher.inspect} isolate=#{@isolate} negate=#{@negate}>" end
Private Instance Methods
Code experiment result.
@param test [::TestTube::Base] The state of the experiment.
@see github.com/fixrb/test_tube
@return [Boolean] The result of the test (passed or failed).
# File lib/spectus/requirement/base.rb, line 74 def passed?(test) test.got.equal?(true) end