Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Provide a more accurate run time by registering start time before cod…

…e is loaded.
  • Loading branch information...
commit fd04952586c048beccd6f6a27dc14f9d82230814 1 parent 9930ff4
@dchelimsky dchelimsky authored
Showing with 3 additions and 3 deletions.
  1. +1 −0  lib/rspec/core.rb
  2. +2 −3 lib/rspec/core/reporter.rb
View
1  lib/rspec/core.rb
@@ -1,3 +1,4 @@
+$rspec_start_time ||= Time.now
require 'rspec/core/dsl'
require 'rspec/core/extensions'
require 'rspec/core/load_path'
View
5 lib/rspec/core/reporter.rb
@@ -3,7 +3,7 @@ class Reporter
def initialize(*formatters)
@formatters = formatters
@example_count = @failure_count = @pending_count = 0
- @duration = @start = nil
+ @duration = nil
end
def report(count)
@@ -30,7 +30,6 @@ def finish
alias_method :abort, :finish
def start(expected_example_count)
- @start = Time.now
notify :start, expected_example_count
end
@@ -66,7 +65,7 @@ def example_pending(example)
end
def stop
- @duration = Time.now - @start if @start
+ @duration = Time.now - $rspec_start_time
notify :stop
end

2 comments on commit fd04952

@rymai

This cause a problem when Spork is used since the start time is set in the prefork block of Spork and duration will then be calculated from this time so it ends up in always increasing duration time. See an issue reported in guard-rspec here: guard/guard-rspec#61

@dchelimsky
Owner

@rymai - can you please submit an issue for this and reference this commit?

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