Skip to content
Browse files

more indentation/display cleanup

  • Loading branch information...
1 parent 37edeaf commit 72fab546bcb91fc67aaa71b2b9f558c535048c5b @geemus geemus committed
Showing with 31 additions and 8 deletions.
  1. +10 −4 lib/shindo.rb
  2. +21 −4 lib/shindo/verbose.rb
View
14 lib/shindo.rb
@@ -59,6 +59,7 @@ def tests(description, tags = [], &block)
@afters.push([])
@description = nil
+ @inline = false
description ||= 'Shindo.tests'
description = "[bold]#{description}[normal]"
unless tags.empty?
@@ -72,16 +73,21 @@ def tests(description, tags = [], &block)
if block_given?
begin
display_description(description)
- Formatador.indent { instance_eval(&block) }
+ # HACK: increase indent
+ indent = Thread.current[:formatador].instance_variable_get(:@indent)
+ Thread.current[:formatador].instance_variable_set(:@indent, indent + 1)
+ instance_eval(&block)
rescue Shindo::Pending
display_pending(description)
- # HACK: remove indent since above doesn't
- indent = Thread.current[:formatador].instance_variable_get(:@indent)
- Thread.current[:formatador].instance_variable_set(:@indent, indent - 1)
rescue => error
display_error(error)
+ ensure
+ # HACK: decrease indent
+ indent = Thread.current[:formatador].instance_variable_get(:@indent)
+ Thread.current[:formatador].instance_variable_set(:@indent, indent - 1)
end
else
+ @inline = true
display_description(description)
end
else
View
25 lib/shindo/verbose.rb
@@ -4,7 +4,12 @@ class Tests
private
def display_description(description)
- Formatador.display_line(description)
+ unless @inline
+ Formatador.display_line(description)
+ else
+ Formatador.display(description)
+ print ' '
+ end
end
def display_error(error)
@@ -18,17 +23,29 @@ def display_error(error)
def display_failure(description)
Thread.current[:totals][:failed] += 1
- Formatador.display_line("[red]- #{description}[/]")
+ unless @inline
+ Formatador.display_line("[red]- #{description}[/]")
+ else
+ print Formatador.parse("[red]- #{description}[/]\n")
+ end
end
def display_pending(description)
Thread.current[:totals][:pending] += 1
- Formatador.display_line("[yellow]# #{description}[/]")
+ unless @inline
+ Formatador.display_line("[yellow]# #{description}[/]")
+ else
+ print Formatador.parse("[yellow]# #{description}[/]\n")
+ end
end
def display_success(description)
Thread.current[:totals][:succeeded] += 1
- Formatador.display_line("[green]+ #{description}[/]")
+ unless @inline
+ Formatador.display_line("[green]+ #{description}[/]")
+ else
+ print Formatador.parse("[green]+ #{description}[/]\n")
+ end
end
end

0 comments on commit 72fab54

Please sign in to comment.
Something went wrong with that request. Please try again.