Skip to content

Instantly share code, notes, and snippets.

@richievos
Created August 29, 2011 03:11
Show Gist options
  • Save richievos/1177705 to your computer and use it in GitHub Desktop.
Save richievos/1177705 to your computer and use it in GitHub Desktop.
Approximation of what adding times to the html formatter would look like -- Final version would be more DRY and what not
diff --git a/vendor/gems/rspec-1.2.9/lib/spec/runner/formatter/html_formatter.rb b/vendor/gems/rspec-1.2.9/lib/spec/runner/formatter/html_formatter.rb
index 2d0c65d..dd86a71 100644
--- a/vendor/gems/rspec-1.2.9/lib/spec/runner/formatter/html_formatter.rb
+++ b/vendor/gems/rspec-1.2.9/lib/spec/runner/formatter/html_formatter.rb
@@ -56,11 +56,12 @@ module Spec
def example_started(example)
@example_number += 1
+ @time = Time.now
end
def example_passed(example)
move_progress
- @output.puts " <dd class=\"spec passed\"><span class=\"passed_spec_name\">#{h(example.description)}</span></dd>"
+ @output.puts " <dd class=\"spec passed\"><span class=\"passed_spec_name\">#{h(example.description)}</span><span class='duration'>#{sprintf("%.1f", Time.now - @time)}s</span></dd>"
@output.flush
end
@@ -73,7 +74,7 @@ module Spec
@example_group_red = true
move_progress
@output.puts " <dd class=\"spec #{failure_style}\">"
- @output.puts " <span class=\"failed_spec_name\">#{h(example.description)}</span>"
+ @output.puts " <span class=\"failed_spec_name\">#{h(example.description)}</span><span class='duration'>#{sprintf("%.1f", Time.now - @time)}s</span>"
@output.puts " <div class=\"failure\" id=\"failure_#{counter}\">"
@output.puts " <div class=\"message\"><pre>#{h(failure.exception.message)}</pre></div>" unless failure.exception.nil?
@output.puts " <div class=\"backtrace\"><pre>#{format_backtrace(failure.exception.backtrace)}</pre></div>" unless failure.exception.nil?
@@ -262,6 +263,13 @@ dd {
padding: 3px 3px 3px 18px;
}
+dd .duration {
+ padding-left: 5px;
+ text-align: right;
+ right: 0px;
+ float:right;
+}
+
dd.spec.passed {
border-left: 5px solid #65C400;
border-bottom: 1px solid #65C400;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment