Module: Minitest::Verify

Defined in:
lib/minitest/verify.rb,
lib/minitest/verify/version.rb

Defined Under Namespace

Classes: VerificationFailedError

Constant Summary collapse

VERSION =
"0.1.1"

Class Attribute Summary collapse

Instance Method Summary collapse

Class Attribute Details

.enabledObject

Returns the value of attribute enabled.



10
11
12
# File 'lib/minitest/verify.rb', line 10

def enabled
  @enabled
end

Instance Method Details

#runObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/minitest/verify.rb', line 26

def run
  # If verification is disabled, run the test normally.
  return super unless Verify.enabled

  super

  # If there are normal failures, don't run verification.
  return Result.from(self) if failures.any?

  begin
    # For each caller, run the test again and verify that it fails.
    while (@current_caller = callers.shift)
      with_verification { super }
    end
  rescue VerificationFailedError
    # If verification fails, break out of the loop.
  end

  Result.from(self)
end

#verify_fails_without(&block) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/minitest/verify.rb', line 13

def verify_fails_without(&block)
  if @current_caller
    # If @current_caller is set, we are in the verification phase.
    # Evaluate the block unless it is the one currently being verified.
    block.call unless caller(1..1).first == @current_caller[0]
  else
    # If @current_caller is not set, we're in the normal test phase.
    # Collect the caller (there might be multiple per test) and evaluate the block.
    callers << caller
    block.call
  end
end