Permalink
Browse files

Merge pull request #451 from richievos/master

Add time to run each example to html formatter.
  • Loading branch information...
2 parents 41c20df + 41f6956 commit 001522bfa00ebf721f05dd274a6b8a11bb592ea9 @dchelimsky dchelimsky committed Nov 15, 2011
Showing with 8 additions and 1 deletion.
  1. +8 −1 lib/rspec/core/formatters/html_formatter.rb
View
9 lib/rspec/core/formatters/html_formatter.rb
@@ -67,7 +67,7 @@ def example_started(example)
def example_passed(example)
move_progress
- @output.puts " <dd class=\"example passed\"><span class=\"passed_spec_name\">#{h(example.description)}</span></dd>"
+ @output.puts " <dd class=\"example passed\"><span class=\"passed_spec_name\">#{h(example.description)}</span><span class='duration'>#{sprintf("%.3f", example.execution_result[:run_time])}s</span></dd>"
@output.flush
end
@@ -84,6 +84,7 @@ def example_failed(example)
move_progress
@output.puts " <dd class=\"example #{failure_style}\">"
@output.puts " <span class=\"failed_spec_name\">#{h(example.description)}</span>"
+ @output.puts " <span class=\"duration\">#{sprintf('%.1f', example.execution_result[:run_time])}s</span>"
@output.puts " <div class=\"failure\" id=\"failure_#{@failed_examples.size}\">"
@output.puts " <div class=\"message\"><pre>#{h(exception.message)}</pre></div>" unless exception.nil?
@output.puts " <div class=\"backtrace\"><pre>#{format_backtrace(exception.backtrace, example).join("\n")}</pre></div>" if exception
@@ -354,6 +355,12 @@ def global_styles
padding: 3px 3px 3px 18px;
}
+dd .duration {
+ padding-left: 5px;
+ text-align: right;
+ right: 0px;
+ float:right;
+}
dd.example.passed {
border-left: 5px solid #65C400;

0 comments on commit 001522b

Please sign in to comment.