Module: TinyTest

Defined in:
lib/tinytest.rb

Instance Method Summary collapse

Instance Method Details

#add_result(msg) ⇒ Object



21
22
23
# File 'lib/tinytest.rb', line 21

def add_result(msg)
  results << "%s (%s:%.3d)" % [msg, *@caller]
end

#doesObject



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/tinytest.rb', line 7

def does
  @caller = caller(1).first.split(":")
  if !yield
    add_result("no. ")
    print_progress :failure
  else
    add_result("yes.") if print_success?
    print_progress :success
  end
rescue Exception => err
  add_result("err.")
  print_progress :error
end

#ioObject



5
# File 'lib/tinytest.rb', line 5

def io; $stderr; end


25
26
27
28
# File 'lib/tinytest.rb', line 25

def print_progress(type)
  _symbol = {:failure => "F", :error => "E"}.fetch(type) {"."}
  io.print _symbol
end


4
# File 'lib/tinytest.rb', line 4

def print_success=(val); @@print_success = !!val; end

Returns:

  • (Boolean)


3
# File 'lib/tinytest.rb', line 3

def print_success?; @@print_success ||= false; end

#resultsObject



2
# File 'lib/tinytest.rb', line 2

def results; @@results ||= []; end