Class: Minitest::Test

Inherits:
Object
  • Object
show all
Defined in:
lib/minitest/proveit.rb,
lib/minitest/proveit.rb

Overview

Hooks Minitest::Test.run to enforce prove_it! for all tests.

TODO: to be moved to minitest/hell?

Constant Summary collapse

VERSION =

:nodoc:

"1.0.0"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.prove_itObject

Getter for prove_it class variable



11
12
13
# File 'lib/minitest/proveit.rb', line 11

def self.prove_it
  @@prove_it ||= false
end

.prove_it!Object

Call this at the top of your tests when you want to force all tests to prove success (via at least one assertion) rather than rely on the absence of failure.



27
28
29
# File 'lib/minitest/proveit.rb', line 27

def self.prove_it!
  @@prove_it = true unless defined? @@prove_it
end

.prove_it=(o) ⇒ Object

Setter for prove_it class variable. true/false



18
19
20
# File 'lib/minitest/proveit.rb', line 18

def self.prove_it= o
  @@prove_it = o
end

.run(reporter, options = {}) ⇒ Object



45
46
47
48
# File 'lib/minitest/proveit.rb', line 45

def self.run reporter, options = {} # :nodoc:
  prove_it!
  super
end

Instance Method Details

#assert_proven?Boolean

:nodoc:

Returns:

  • (Boolean)


33
34
35
36
# File 'lib/minitest/proveit.rb', line 33

def assert_proven? # :nodoc:
  flunk "Absence of failure is not success. Prove it!" if
    self.class.prove_it && self.failures.empty? && self.assertions == 0
end