summary refs log tree commit diff
path: root/lib
diff options
context:
space:
mode:
authorGabriel Horner <gabriel.horner@gmail.com>2010-04-14 05:40:31 -0400
committerGabriel Horner <gabriel.horner@gmail.com>2010-04-14 05:40:31 -0400
commitb90543f46b94af5d5c24720d8dce59e839c7409e (patch)
tree5e19f210042959850f8ae23fbebca3186d25f52b /lib
parentc230d01063b1ca9ade3bd12275033edd5a8b032b (diff)
downloadbacon-b90543f46b94af5d5c24720d8dce59e839c7409e.tar.gz
bacon-b90543f46b94af5d5c24720d8dce59e839c7409e.tar.xz
bacon-b90543f46b94af5d5c24720d8dce59e839c7409e.zip
Indent nested contexts for SpecDoxOutput
Based on similar patch from http://github.com/wvl/bacon/commit/af940dbeb789f5eef2d998e227e5425d
Diffstat (limited to 'lib')
-rw-r--r--lib/bacon.rb12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/bacon.rb b/lib/bacon.rb
index 371e9ab..c3c4f4f 100644
--- a/lib/bacon.rb
+++ b/lib/bacon.rb
@@ -38,13 +38,13 @@ module Bacon
 
   module SpecDoxOutput
     def handle_specification(name)
-      puts name
+      puts spaces + name
       yield
-      puts
+      puts if Counter[:context_depth] == 1
     end
 
     def handle_requirement(description)
-      print "- #{description}"
+      print "#{spaces}  - #{description}"
       error = yield
       puts error.empty? ? "" : " [#{error}]"
     end
@@ -54,6 +54,10 @@ module Bacon
       puts "%d specifications (%d requirements), %d failures, %d errors" %
         Counter.values_at(:specifications, :requirements, :failed, :errors)
     end
+
+    def spaces
+      "  " * (Counter[:context_depth] - 1)
+    end
   end
 
   module TestUnitOutput
@@ -137,7 +141,9 @@ module Bacon
     
     def run
       return  unless name =~ RestrictContext
+      Counter[:context_depth] += 1
       Bacon.handle_specification(name) { instance_eval(&block) }
+      Counter[:context_depth] -= 1
       self
     end