Module: TinyTest
- Defined in:
- lib/tinytest.rb
Instance Method Summary collapse
- #add_result(msg) ⇒ Object
- #does ⇒ Object
- #io ⇒ Object
- #print_progress(type) ⇒ Object
- #print_success=(val) ⇒ Object
- #print_success? ⇒ Boolean
- #results ⇒ Object
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 |
#does ⇒ Object
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 |
#io ⇒ Object
5 |
# File 'lib/tinytest.rb', line 5 def io; $stderr; end |
#print_progress(type) ⇒ Object
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 |
#print_success=(val) ⇒ Object
4 |
# File 'lib/tinytest.rb', line 4 def print_success=(val); @@print_success = !!val; end |
#print_success? ⇒ Boolean
3 |
# File 'lib/tinytest.rb', line 3 def print_success?; @@print_success ||= false; end |
#results ⇒ Object
2 |
# File 'lib/tinytest.rb', line 2 def results; @@results ||= []; end |