summary refs log tree commit diff
path: root/lib
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2007-05-31 14:28:35 +0200
committerChristian Neukirchen <chneukirchen@gmail.com>2007-05-31 14:28:35 +0200
commitafa9a65636cdc39c7d913a359689cf972c549bee (patch)
tree5d90ea4ae0b2000655123ea10ab477ff7675a71f /lib
parentf2c89a8c06919e82b17145392a68e0cd402e6c0b (diff)
downloadbacon-afa9a65636cdc39c7d913a359689cf972c549bee.tar.gz
bacon-afa9a65636cdc39c7d913a359689cf972c549bee.tar.xz
bacon-afa9a65636cdc39c7d913a359689cf972c549bee.zip
Add Test::Unit-like output (-q)
darcs-hash:20070531122835-4fc50-fb4b446c031828f7d8e813878ec864423de9c6dc.gz
Diffstat (limited to 'lib')
-rw-r--r--lib/bacon.rb60
1 files changed, 45 insertions, 15 deletions
diff --git a/lib/bacon.rb b/lib/bacon.rb
index df2cee6..4b0cf58 100644
--- a/lib/bacon.rb
+++ b/lib/bacon.rb
@@ -7,28 +7,58 @@ module Bacon
   Counter = Hash.new(0)
   ErrorLog = ""
 
-  def self.result_string
-    "%d specifications (%d requirements), %d failures, %d errors" % 
-      [Counter[:specifications], Counter[:requirements],
-       Counter[:failed],         Counter[:errors]]
-  end
+  module SpecDoxOutput
+    def handle_specification(name)
+      puts name
+      yield
+      puts
+    end
 
-  def self.handle_specification(name)
-    puts name
-    yield
-    puts
+    def handle_requirement(description)
+      print "- #{description}"
+      error = yield
+      if error.empty?
+        puts
+      else
+        puts " [#{error}]"
+      end
+    end
+
+    def handle_summary
+      puts Bacon::ErrorLog
+      puts "%d specifications (%d requirements), %d failures, %d errors" % 
+           [Counter[:specifications], Counter[:requirements],
+            Counter[:failed],         Counter[:errors]]
+      p Bacon::Counter
+    end
   end
 
-  def self.handle_requirement(description)
-    print "- #{description}"
-    error = yield
-    if error.empty?
+  module TestUnitOutput
+    def handle_specification(name)
+      yield
+    end
+
+    def handle_requirement(description)
+      error = yield
+      if error.empty?
+        print "."
+      else
+        print error[0..0]
+      end
+    end
+
+    def handle_summary
       puts
-    else
-      puts " [#{error}]"
+      puts Bacon::ErrorLog
+      puts "%d tests, %d assertions, %d failures, %d errors" % 
+           [Counter[:specifications], Counter[:requirements],
+            Counter[:failed],         Counter[:errors]]
+      p Bacon::Counter
     end
   end
 
+  extend SpecDoxOutput          # default
+
   class Error < RuntimeError
     attr_accessor :count_as