From b90543f46b94af5d5c24720d8dce59e839c7409e Mon Sep 17 00:00:00 2001 From: Gabriel Horner Date: Wed, 14 Apr 2010 05:40:31 -0400 Subject: Indent nested contexts for SpecDoxOutput Based on similar patch from http://github.com/wvl/bacon/commit/af940dbeb789f5eef2d998e227e5425d --- lib/bacon.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'lib') 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 -- cgit 1.4.1