nofxx-rspec_spinner 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 1
3
- :minor: 0
3
+ :minor: 1
4
4
  :patch: 0
@@ -11,6 +11,11 @@ module RspecSpinner
11
11
 
12
12
  attr_reader :total, :current
13
13
 
14
+ def initialize(options, where)
15
+ super
16
+ @example_times = []
17
+ end
18
+
14
19
  def start(example_count)
15
20
  @current = 0
16
21
  @total = example_count
@@ -25,9 +30,9 @@ module RspecSpinner
25
30
  end
26
31
 
27
32
  def example_passed(example)
28
- print_warning_if_slow(example_group.description,
29
- example.description, example.location,
30
- Time.now - @start_time)
33
+ ex = [example_group.description, example.description, example.location, Time.now - @start_time]
34
+ print_warning_if_slow(*ex)
35
+ @example_times << ex
31
36
  increment
32
37
  end
33
38
 
@@ -46,6 +51,19 @@ module RspecSpinner
46
51
 
47
52
  def start_dump
48
53
  output.flush
54
+ super
55
+ @output.puts "\n\nTop 15 slowest examples:\n"
56
+
57
+ @example_times = @example_times.sort_by do |description, example, location, time|
58
+ time
59
+ end.reverse
60
+
61
+ @example_times[0..14].each do |description, example, location, time|
62
+ _,line = location.split(":")
63
+ @output.print red(sprintf("%.7f", time))
64
+ @output.puts " #{description}:#{line} #{example}"
65
+ end
66
+ @output.flush
49
67
  end
50
68
 
51
69
  def dump_failure(*args)
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{rspec_spinner}
5
- s.version = "1.0.0"
5
+ s.version = "1.1.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Marcos Augusto"]
9
- s.date = %q{2009-05-08}
9
+ s.date = %q{2009-05-20}
10
10
  s.email = %q{Cool Extra formatters for Rspec}
11
11
  s.extra_rdoc_files = [
12
12
  "README.rdoc"
@@ -30,17 +30,16 @@ Gem::Specification.new do |s|
30
30
  "spec/spec.opts",
31
31
  "spec/spec_helper.rb"
32
32
  ]
33
- s.has_rdoc = true
34
33
  s.homepage = %q{http://github.com/nofxx/rspec_spinner}
35
34
  s.rdoc_options = ["--charset=UTF-8"]
36
35
  s.require_paths = ["lib"]
37
- s.rubygems_version = %q{1.3.2}
36
+ s.rubygems_version = %q{1.3.3}
38
37
  s.summary = %q{Extra formatters for Rspec}
39
38
  s.test_files = [
40
- "spec/rspec_spinner/spinner_spec.rb",
41
- "spec/rspec_spinner/base_spec.rb",
42
- "spec/spec_helper.rb",
43
- "spec/rspec_spinner_spec.rb"
39
+ "spec/rspec_spinner/base_spec.rb",
40
+ "spec/rspec_spinner/spinner_spec.rb",
41
+ "spec/rspec_spinner_spec.rb",
42
+ "spec/spec_helper.rb"
44
43
  ]
45
44
 
46
45
  if s.respond_to? :specification_version then
@@ -12,7 +12,7 @@ describe "Base" do
12
12
 
13
13
  it "should produce line break on start dump" do
14
14
  @formatter.start_dump
15
- @io.string.should eql("")
15
+ @io.string.should eql("\n\nTop 10 slowest examples:\n")
16
16
  end
17
17
 
18
18
  it "should produce standard summary without pending when pending has a 0 count" do
@@ -48,7 +48,6 @@ describe "Base" do
48
48
  end
49
49
 
50
50
  it "should update status and go green for passing spec" do
51
- pending
52
51
  @example = mock("Example", :description => "Foo") #@passing_group.examples.first
53
52
  @io.should_receive(:tty?).and_return(true)
54
53
  @options.should_receive(:colour).and_return(true)
@@ -96,9 +95,9 @@ describe "Base" do
96
95
  it "should push slow specs" do
97
96
  # @io.should_receive(:tty?).and_return(true)
98
97
  @options.should_receive(:colour).and_return(true)
99
- Time.should_receive(:now).and_return(Date.parse "10/10/2000 10:10:10")
100
- Time.should_receive(:now).and_return(Date.parse "10/10/2009 10:10:10")
98
+ Time.should_receive(:now).at_least(11).times.and_return(Date.parse("10/10/2000 10:10:10"), Date.parse("10/10/2009 10:10:10"))
101
99
  @mock_slow = mock("SLOW", :description => "Pending Fixed", :location => "Foo")
100
+ @formatter.should_receive(:example_group).and_return(mock("Group", :description => "Cool"))
102
101
  @formatter.start(1)
103
102
  @formatter.example_started(@mock_slow)
104
103
  @formatter.example_passed(@mock_slow)
@@ -114,6 +113,20 @@ describe "Base" do
114
113
  @formatter.dump_failure.should be_nil
115
114
  end
116
115
 
116
+ it "should dump the slowest ones in the end" do
117
+
118
+ @options.should_receive(:colour).and_return(true)
119
+ @options.should_receive(:autospec).and_return(true)
120
+ @formatter.start(1)
121
+ @mock_message = mock("PENDING", :description => "Oi", :backtrace => "Bad", :location => "Foo l 20")
122
+ @formatter.example_pending(@mock_message, "Teste")
123
+ @io.string.should eql("\r
124
+ @formatter.start_dump
125
+ @io.string.should eql("\n\nTop 10 slowest examples:\n")
126
+
127
+
128
+ end
129
+
117
130
  it "should ignore method missing" do
118
131
  @formatter.method_missing(:foo).should be_nil
119
132
  end
@@ -1,4 +1,4 @@
1
1
  --colour
2
2
  --diff
3
3
  --reverse
4
- --format progress
4
+ --format profile
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nofxx-rspec_spinner
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcos Augusto
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-05-08 00:00:00 -07:00
12
+ date: 2009-05-20 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -58,7 +58,7 @@ files:
58
58
  - spec/rspec_spinner_spec.rb
59
59
  - spec/spec.opts
60
60
  - spec/spec_helper.rb
61
- has_rdoc: true
61
+ has_rdoc: false
62
62
  homepage: http://github.com/nofxx/rspec_spinner
63
63
  post_install_message:
64
64
  rdoc_options:
@@ -85,7 +85,7 @@ signing_key:
85
85
  specification_version: 3
86
86
  summary: Extra formatters for Rspec
87
87
  test_files:
88
- - spec/rspec_spinner/spinner_spec.rb
89
88
  - spec/rspec_spinner/base_spec.rb
90
- - spec/spec_helper.rb
89
+ - spec/rspec_spinner/spinner_spec.rb
91
90
  - spec/rspec_spinner_spec.rb
91
+ - spec/spec_helper.rb