Class: Minitest::Homework

Inherits:
Test
  • Object
show all
Defined in:
lib/minitest/homework.rb,
lib/minitest/homework/version.rb

Constant Summary collapse

VERSION =
"0.0.1"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.be_gentle!Object



6
7
8
# File 'lib/minitest/homework.rb', line 6

def self.be_gentle!
  Minitest::SummaryReporter.be_gentle!
end

.runnable_methodsObject



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

def self.runnable_methods
  methods_matching(/^test_/)
end

Instance Method Details

#__Object



14
15
16
# File 'lib/minitest/homework.rb', line 14

def __
  :blank
end

#assert_equal(actual, expected) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/minitest/homework.rb', line 18

def assert_equal(actual, expected)
  if actual == __
    begin
      raise
    rescue => e
      failure = Exception.new("Fill in the blank, then re-run the test.")
      failure.set_backtrace e.backtrace[1..-1]
      raise failure
    end
  else
    super
  end
end

#maybe(boolean) ⇒ Object



32
33
34
35
36
37
38
39
40
# File 'lib/minitest/homework.rb', line 32

def maybe(boolean)
  begin
    raise
  rescue => e
    failure = Exception.new("Replace `maybe` with either `assert` or `refute`, then re-run the test.")
    failure.set_backtrace e.backtrace[1..-1]
    raise failure
  end
end