Module: Mathtestsuite

Defined in:
lib/mathtestsuite.rb

Instance Method Summary collapse

Instance Method Details

#assert(expected:, actual:) ⇒ Object



4
5
6
7
8
# File 'lib/mathtestsuite.rb', line 4

def assert(expected:, actual:)
  success = expected == actual
  print success ? '.'.cyan : 'F'.red
   {success: success, expected: expected, actual: actual}
end

#run_testsObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/mathtestsuite.rb', line 10

def run_tests
  specs = []
  self.class.instance_methods(false ).each do |method_name|
    spec = public_send(method_name)
    spec[:method_name] = method_name
    specs << spec
  end
  puts
  errored_specs = specs.reject { |spec| spec[:success] }
  errored_specs.each { |spec|
    puts "FAILED: #{spec[:method_name]}".red
    puts "EXPECTED: #{spec[:expected]}".blue
    puts "ACTUAL: #{spec[:actual]}".cyan
  }
end