rspec_spinner 1.1.3 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +2 -0
- data/README.rdoc +13 -0
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/rspec_spinner.rb +3 -2
- data/lib/rspec_spinner/base.rb +34 -17
- data/rspec_spinner.gemspec +24 -26
- data/spec/rspec_spinner/base_spec.rb +4 -1
- data/spec/spec_helper.rb +9 -2
- metadata +21 -31
- data/.gitignore +0 -7
data/.rspec
ADDED
data/README.rdoc
CHANGED
@@ -32,6 +32,19 @@ Require RspecSpinner on spec/spec_helper.rb:
|
|
32
32
|
...
|
33
33
|
|
34
34
|
|
35
|
+
=== Rspec 2.x
|
36
|
+
|
37
|
+
Add to your project /.rspec
|
38
|
+
|
39
|
+
--require rspec_spinner --format RspecSpinner::Bar
|
40
|
+
|
41
|
+
or:
|
42
|
+
|
43
|
+
--require rspec_spinner --format RspecSpinner::Spinner
|
44
|
+
|
45
|
+
|
46
|
+
=== Rspec 1.x
|
47
|
+
|
35
48
|
Change your spec.opts --format to:
|
36
49
|
|
37
50
|
--format RspecSpinner::Bar
|
data/Rakefile
CHANGED
@@ -8,7 +8,7 @@ begin
|
|
8
8
|
gem.summary = "Extra formatters for Rspec"
|
9
9
|
gem.email = "Cool Extra formatters for Rspec"
|
10
10
|
gem.homepage = "http://github.com/nofxx/rspec_spinner"
|
11
|
-
gem.authors = ["Marcos
|
11
|
+
gem.authors = ["Marcos Piccinini"]
|
12
12
|
gem.add_dependency 'rtui'
|
13
13
|
gem.add_development_dependency 'rspec'
|
14
14
|
gem.post_install_message = <<-POST_INSTALL_MESSAGE
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
2.0.0
|
data/lib/rspec_spinner.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
$:.unshift(File.dirname(__FILE__)) unless
|
2
|
-
|
1
|
+
# $:.unshift(File.dirname(__FILE__)) unless
|
2
|
+
# $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
3
3
|
#require "spec/runner/options"
|
4
4
|
require "rspec_spinner/base"
|
5
5
|
require "rspec_spinner/spinner"
|
@@ -12,3 +12,4 @@ require "rspec_spinner/bar"
|
|
12
12
|
# end
|
13
13
|
## end
|
14
14
|
#end
|
15
|
+
|
data/lib/rspec_spinner/base.rb
CHANGED
@@ -1,9 +1,15 @@
|
|
1
|
-
|
1
|
+
begin
|
2
|
+
require "spec/runner/formatter/base_text_formatter"
|
3
|
+
rescue LoadError
|
4
|
+
require "rspec/core/formatters/base_text_formatter"
|
5
|
+
end
|
6
|
+
|
2
7
|
require "rubygems"
|
3
8
|
require "rtui"
|
4
9
|
|
10
|
+
|
5
11
|
module RspecSpinner
|
6
|
-
class RspecSpinnerBase <
|
12
|
+
class RspecSpinnerBase < RSpec::Core::Formatters::BaseTextFormatter
|
7
13
|
# Threshold for slow specs, in seconds.
|
8
14
|
# Anything that takes longer than this will be printed out
|
9
15
|
#THRESHOLD = 0.25
|
@@ -11,17 +17,17 @@ module RspecSpinner
|
|
11
17
|
|
12
18
|
attr_reader :total, :current
|
13
19
|
|
14
|
-
def initialize(options, where)
|
15
|
-
super
|
20
|
+
def initialize(options, where=nil)
|
21
|
+
super options
|
16
22
|
@example_times = []
|
17
23
|
end
|
18
24
|
|
19
25
|
def start(example_count)
|
20
|
-
@current
|
21
|
-
@total
|
26
|
+
@current = 0
|
27
|
+
@total = example_count
|
22
28
|
@error_state = :all_passing
|
23
|
-
@pbar
|
24
|
-
|
29
|
+
@pbar = RTUI::Progress.new("#{example_count} examples", example_count,
|
30
|
+
{:out => output, :components => [:percentage, :spinner, :stat]})
|
25
31
|
end
|
26
32
|
|
27
33
|
def example_started(example)
|
@@ -59,7 +65,7 @@ module RspecSpinner
|
|
59
65
|
end.reverse
|
60
66
|
|
61
67
|
@example_times[0..14].each do |description, example, location, time|
|
62
|
-
_,line = location.split(":")
|
68
|
+
_, line = location.split(":")
|
63
69
|
@output.print red(sprintf("%.7f", time))
|
64
70
|
@output.puts " #{description}:#{line} #{example}"
|
65
71
|
end
|
@@ -74,6 +80,11 @@ module RspecSpinner
|
|
74
80
|
# ignore
|
75
81
|
end
|
76
82
|
|
83
|
+
def self.fmt_backtrace(bkt)
|
84
|
+
return "" if bkt.nil?
|
85
|
+
return bkt.split("\n")
|
86
|
+
end
|
87
|
+
|
77
88
|
# stolen and slightly modified from BaseTextFormatter#dump_failure
|
78
89
|
def immediately_dump_failure(counter, failure)
|
79
90
|
erase_current_line
|
@@ -81,15 +92,16 @@ module RspecSpinner
|
|
81
92
|
output.print "#{counter.to_s}) "
|
82
93
|
# Rspec 1.2.2
|
83
94
|
output.puts colorize_failure("#{failure.header}\n#{failure.exception.message}", failure)
|
84
|
-
output.puts
|
95
|
+
output.puts failure.exception.backtrace
|
85
96
|
output.puts
|
86
97
|
end
|
87
98
|
|
99
|
+
|
88
100
|
# stolen and modified from BaseTextFormatter#dump_pending
|
89
101
|
def immediately_dump_pending(desc, msg, location)
|
90
102
|
erase_current_line
|
91
103
|
output.puts yellow("PENDING SPEC:") + " #{desc} (#{msg})"
|
92
|
-
output.puts
|
104
|
+
output.puts " Called from #{location}"
|
93
105
|
output.puts
|
94
106
|
end
|
95
107
|
|
@@ -97,18 +109,23 @@ module RspecSpinner
|
|
97
109
|
with_color do
|
98
110
|
@current += 1
|
99
111
|
# HACK: need to make sure the progress is printed, even when the bar hasn't changed
|
100
|
-
|
101
|
-
|
112
|
+
if /^1\.8/ === RUBY_VERSION then
|
113
|
+
@pbar.instance_variable_set("@previous", 0)
|
114
|
+
@pbar.instance_variable_set("@title", "#{current}/#{total}")
|
115
|
+
else
|
116
|
+
@pbar.instance_variable_set("@previous".to_sym, 0)
|
117
|
+
@pbar.instance_variable_set("@title".to_sym, "#{current}/#{total}")
|
118
|
+
end
|
102
119
|
@pbar.inc
|
103
120
|
end
|
104
121
|
output.flush
|
105
122
|
end
|
106
123
|
|
107
124
|
ERROR_STATE_COLORS = {
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
125
|
+
:all_passing => "\e[32m", # green
|
126
|
+
:some_pending => "\e[33m", # yellow
|
127
|
+
:some_failed => "\e[31m", # red
|
128
|
+
:pending_fix => "\e[34m", # blue
|
112
129
|
}
|
113
130
|
|
114
131
|
def with_color
|
data/rspec_spinner.gemspec
CHANGED
@@ -1,35 +1,34 @@
|
|
1
1
|
# Generated by jeweler
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{rspec_spinner}
|
8
|
-
s.version = "
|
8
|
+
s.version = "2.0.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Marcos
|
12
|
-
s.date = %q{
|
11
|
+
s.authors = ["Marcos Piccinini"]
|
12
|
+
s.date = %q{2011-04-15}
|
13
13
|
s.email = %q{Cool Extra formatters for Rspec}
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"README.rdoc"
|
16
16
|
]
|
17
17
|
s.files = [
|
18
|
-
"
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
"spec/spec_helper.rb"
|
18
|
+
"MIT-LICENSE",
|
19
|
+
"README.rdoc",
|
20
|
+
"Rakefile",
|
21
|
+
"VERSION",
|
22
|
+
"lib/rspec_spinner.rb",
|
23
|
+
"lib/rspec_spinner/bar.rb",
|
24
|
+
"lib/rspec_spinner/base.rb",
|
25
|
+
"lib/rspec_spinner/spinner.rb",
|
26
|
+
"rspec_spinner.gemspec",
|
27
|
+
"spec/rspec_spinner/base_spec.rb",
|
28
|
+
"spec/rspec_spinner/spinner_spec.rb",
|
29
|
+
"spec/rspec_spinner_spec.rb",
|
30
|
+
"spec/spec.opts",
|
31
|
+
"spec/spec_helper.rb"
|
33
32
|
]
|
34
33
|
s.homepage = %q{http://github.com/nofxx/rspec_spinner}
|
35
34
|
s.post_install_message = %q{
|
@@ -52,22 +51,21 @@ or:
|
|
52
51
|
Have fun!
|
53
52
|
|
54
53
|
}
|
55
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
56
54
|
s.require_paths = ["lib"]
|
57
|
-
s.rubygems_version = %q{1.3.
|
55
|
+
s.rubygems_version = %q{1.3.7}
|
58
56
|
s.summary = %q{Extra formatters for Rspec}
|
59
57
|
s.test_files = [
|
60
|
-
"spec/
|
61
|
-
|
62
|
-
|
63
|
-
|
58
|
+
"spec/rspec_spinner/base_spec.rb",
|
59
|
+
"spec/rspec_spinner/spinner_spec.rb",
|
60
|
+
"spec/rspec_spinner_spec.rb",
|
61
|
+
"spec/spec_helper.rb"
|
64
62
|
]
|
65
63
|
|
66
64
|
if s.respond_to? :specification_version then
|
67
65
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
68
66
|
s.specification_version = 3
|
69
67
|
|
70
|
-
if Gem::Version.new(Gem::
|
68
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
71
69
|
s.add_runtime_dependency(%q<rtui>, [">= 0"])
|
72
70
|
s.add_development_dependency(%q<rspec>, [">= 0"])
|
73
71
|
else
|
@@ -7,6 +7,9 @@ describe "Base" do
|
|
7
7
|
@options = mock('options')
|
8
8
|
@options.stub!(:dry_run).and_return(false)
|
9
9
|
@options.stub!(:colour).and_return(false)
|
10
|
+
@options.stub!(:print)
|
11
|
+
@options.stub!(:flush)
|
12
|
+
@options.stub!(:puts)
|
10
13
|
@formatter = RspecSpinner::Bar.new(@options, @io)
|
11
14
|
end
|
12
15
|
|
@@ -16,7 +19,7 @@ describe "Base" do
|
|
16
19
|
end
|
17
20
|
|
18
21
|
it "should produce standard summary without pending when pending has a 0 count" do
|
19
|
-
|
22
|
+
@options.should_receive(:autospec).and_return(true)
|
20
23
|
@formatter.dump_summary(3, 2, 1, 0)
|
21
24
|
@io.string.should eql("\nFinished in 3 seconds\n\n2 examples, 1 failure\n")
|
22
25
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -3,8 +3,15 @@ begin
|
|
3
3
|
rescue LoadError
|
4
4
|
require 'rubygems'
|
5
5
|
gem 'rspec'
|
6
|
-
require '
|
6
|
+
require 'rspec'
|
7
7
|
end
|
8
|
+
require 'rspec_spinner'
|
9
|
+
|
10
|
+
config = RSpec.configuration
|
11
|
+
# we want to use colored output for the console, right?
|
12
|
+
config.color_enabled = true
|
13
|
+
documentation_formatter = config.send(:built_in_formatter, :documentation).new(config.output)
|
14
|
+
custom_formatter = RspecSpinner::Spinner.new(STDOUT)
|
15
|
+
config.instance_variable_set(:@reporter, RSpec::Core::Reporter.new(documentation_formatter, custom_formatter))
|
8
16
|
|
9
17
|
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
10
|
-
require 'rspec_spinner'
|
metadata
CHANGED
@@ -3,24 +3,25 @@ name: rspec_spinner
|
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
|
-
-
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version:
|
6
|
+
- 2
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
version: 2.0.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
|
-
- Marcos
|
12
|
+
- Marcos Piccinini
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date:
|
17
|
+
date: 2011-04-15 00:00:00 -03:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: rtui
|
22
22
|
prerelease: false
|
23
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
24
25
|
requirements:
|
25
26
|
- - ">="
|
26
27
|
- !ruby/object:Gem::Version
|
@@ -33,6 +34,7 @@ dependencies:
|
|
33
34
|
name: rspec
|
34
35
|
prerelease: false
|
35
36
|
requirement: &id002 !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
36
38
|
requirements:
|
37
39
|
- - ">="
|
38
40
|
- !ruby/object:Gem::Version
|
@@ -50,7 +52,7 @@ extensions: []
|
|
50
52
|
extra_rdoc_files:
|
51
53
|
- README.rdoc
|
52
54
|
files:
|
53
|
-
- .
|
55
|
+
- .rspec
|
54
56
|
- MIT-LICENSE
|
55
57
|
- README.rdoc
|
56
58
|
- Rakefile
|
@@ -69,31 +71,18 @@ has_rdoc: true
|
|
69
71
|
homepage: http://github.com/nofxx/rspec_spinner
|
70
72
|
licenses: []
|
71
73
|
|
72
|
-
post_install_message:
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
...
|
81
|
-
|
82
|
-
Change your spec.opts --format to:
|
83
|
-
|
84
|
-
--format RspecSpinner::Bar
|
85
|
-
|
86
|
-
or:
|
87
|
-
|
88
|
-
--format RspecSpinner::Spinner
|
89
|
-
|
90
|
-
Have fun!
|
91
|
-
|
92
|
-
rdoc_options:
|
93
|
-
- --charset=UTF-8
|
74
|
+
post_install_message: "\n\
|
75
|
+
50% |========= RSPEC_SPINNER =========|\n\n\
|
76
|
+
Require it on spec/spec_helper.rb:\n\n require 'spec'\n require 'rspec_spinner'\n ...\n\n\
|
77
|
+
Change your spec.opts --format to:\n\n --format RspecSpinner::Bar\n\n\
|
78
|
+
or:\n\n --format RspecSpinner::Spinner\n\n\
|
79
|
+
Have fun!\n\n"
|
80
|
+
rdoc_options: []
|
81
|
+
|
94
82
|
require_paths:
|
95
83
|
- lib
|
96
84
|
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
97
86
|
requirements:
|
98
87
|
- - ">="
|
99
88
|
- !ruby/object:Gem::Version
|
@@ -101,6 +90,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
101
90
|
- 0
|
102
91
|
version: "0"
|
103
92
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
none: false
|
104
94
|
requirements:
|
105
95
|
- - ">="
|
106
96
|
- !ruby/object:Gem::Version
|
@@ -110,12 +100,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
100
|
requirements: []
|
111
101
|
|
112
102
|
rubyforge_project:
|
113
|
-
rubygems_version: 1.3.
|
103
|
+
rubygems_version: 1.3.7
|
114
104
|
signing_key:
|
115
105
|
specification_version: 3
|
116
106
|
summary: Extra formatters for Rspec
|
117
107
|
test_files:
|
118
|
-
- spec/spec_helper.rb
|
119
108
|
- spec/rspec_spinner/base_spec.rb
|
120
109
|
- spec/rspec_spinner/spinner_spec.rb
|
121
110
|
- spec/rspec_spinner_spec.rb
|
111
|
+
- spec/spec_helper.rb
|