instant_disappointment 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -17,14 +17,14 @@ h1. Usage
17
17
  If you run @spec@ from the command line:
18
18
 
19
19
  <pre>
20
- spec --require instant_disappointment_formatter --formatter Spec::Runner::Formatter::InstantDisappointmentFormatter <your_specfiles_here>
20
+ spec --require instant_disappointment_formatter --format Spec::Runner::Formatter::InstantDisappointmentFormatter <your_specfiles_here>
21
21
  </pre>
22
22
 
23
23
  If you use a @spec.opts@ file:
24
24
 
25
25
  <pre>
26
26
  --require instant_disappointment_formatter
27
- --formatter Spec::Runner::Formatter::InstantDisappointmentFormatter
27
+ --format Spec::Runner::Formatter::InstantDisappointmentFormatter
28
28
  </pre>
29
29
 
30
30
  h1. Example
@@ -4,7 +4,27 @@ module Spec
4
4
  module Runner
5
5
  module Formatter
6
6
  class InstantDisappointmentFormatter < ProgressBarFormatter
7
- VERSION = "1.0.0"
7
+ VERSION = "1.1.0"
8
+ SHOW_TOP = (ENV['PROFILE_SHOW_TOP'] || 20).to_i
9
+
10
+ def initialize(*args)
11
+ super
12
+ @example_times = []
13
+ end
14
+
15
+ def example_started(*args)
16
+ @time = Time.now
17
+ end
18
+
19
+ def example_passed(example)
20
+ super
21
+ @example_times << [
22
+ example_group.description,
23
+ example.description,
24
+ Time.now - @time
25
+ ]
26
+ end
27
+
8
28
  alias :example_failed_without_instant_disappointment :example_failed
9
29
  alias :dump_failure_without_lockout :dump_failure
10
30
 
@@ -22,8 +42,38 @@ module Spec
22
42
  end
23
43
 
24
44
  def start_dump
45
+ dump_group_times
46
+ dump_example_times
25
47
  @in_dump = true
26
48
  end
49
+
50
+ private
51
+
52
+ def dump_example_times
53
+ @output.puts "\n\nSingle examples:\n"
54
+
55
+ sorted_by_time(@example_times)[0..SHOW_TOP].each do |group, example, time|
56
+ @output.puts "#{red(sprintf("%.7f", time))} #{group} #{example}"
57
+ end
58
+ end
59
+
60
+ def dump_group_times
61
+ @output.puts "\n\nGroups:\n"
62
+
63
+ group_times = Hash.new(0)
64
+ @example_times.each do |group, example, time|
65
+ group_times[group]+=time
66
+ end
67
+
68
+ sorted_by_time(group_times)[0..SHOW_TOP].each do |group,time|
69
+ @output.puts "#{red(sprintf("%.7f", time))} #{group}"
70
+ end
71
+ end
72
+
73
+ #sorted by last ascending
74
+ def sorted_by_time(times)
75
+ times.to_a.sort_by{|x| x.last}.reverse
76
+ end
27
77
  end
28
78
  end
29
79
  end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: instant_disappointment
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 19
4
5
  prerelease: false
5
6
  segments:
6
7
  - 1
8
+ - 1
7
9
  - 0
8
- - 0
9
- version: 1.0.0
10
+ version: 1.1.0
10
11
  platform: ruby
11
12
  authors:
12
13
  - Danny Burkes
@@ -14,16 +15,18 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-10-22 00:00:00 -07:00
18
+ date: 2011-07-18 00:00:00 -07:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: rspec
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
24
26
  requirements:
25
27
  - - ">="
26
28
  - !ruby/object:Gem::Version
29
+ hash: 3
27
30
  segments:
28
31
  - 0
29
32
  version: "0"
@@ -51,23 +54,27 @@ rdoc_options: []
51
54
  require_paths:
52
55
  - lib
53
56
  required_ruby_version: !ruby/object:Gem::Requirement
57
+ none: false
54
58
  requirements:
55
59
  - - ">="
56
60
  - !ruby/object:Gem::Version
61
+ hash: 3
57
62
  segments:
58
63
  - 0
59
64
  version: "0"
60
65
  required_rubygems_version: !ruby/object:Gem::Requirement
66
+ none: false
61
67
  requirements:
62
68
  - - ">="
63
69
  - !ruby/object:Gem::Version
70
+ hash: 3
64
71
  segments:
65
72
  - 0
66
73
  version: "0"
67
74
  requirements: []
68
75
 
69
76
  rubyforge_project: instant_disappointment
70
- rubygems_version: 1.3.6
77
+ rubygems_version: 1.3.7
71
78
  signing_key:
72
79
  specification_version: 3
73
80
  summary: No time for ping pong- start fixing the specs now!