nofxx-rspec_spinner 0.4.5 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +2 -0
- data/README.rdoc +9 -9
- data/Rakefile +2 -2
- data/lib/rspec_spinner/base.rb +5 -9
- data/lib/rspec_spinner/spinner.rb +4 -2
- data/lib/rspec_spinner.rb +1 -1
- data/rspec_spinner.gemspec +8 -8
- data/spec/rspec_spinner/base_spec.rb +117 -0
- data/spec/rspec_spinner/spinner_spec.rb +28 -0
- data/spec/rspec_spinner_spec.rb +2 -4
- data/spec/spec.opts +2 -1
- data/spec/spec_helper.rb +1 -1
- metadata +7 -5
data/Manifest.txt
CHANGED
data/README.rdoc
CHANGED
@@ -12,12 +12,17 @@ Adds an extra formatter that looks like this:
|
|
12
12
|
|
13
13
|
Or this:
|
14
14
|
|
15
|
-
46% \
|
15
|
+
46% \ should get Bar ETA: 00:00:23
|
16
16
|
|
17
17
|
|
18
18
|
No dots and Fs, just what you need to know: FAILURES, PENDINGS and SLOW ones.
|
19
19
|
|
20
20
|
|
21
|
+
== INSTALL:
|
22
|
+
|
23
|
+
sudo gem install rspec_spinner
|
24
|
+
|
25
|
+
|
21
26
|
== TO USE:
|
22
27
|
|
23
28
|
Require RspecSpinner on spec/spec_helper.rb:
|
@@ -37,23 +42,18 @@ or:
|
|
37
42
|
|
38
43
|
|
39
44
|
Have fun!
|
40
|
-
|
45
|
+
|
41
46
|
|
42
47
|
== REQUIREMENTS:
|
43
48
|
|
44
|
-
* rspec
|
49
|
+
* rspec (http://github.com/dchemlinksy/rspec)
|
45
50
|
* rtui (http://github.com/nofxx/rtui)
|
46
51
|
|
47
52
|
|
48
|
-
== INSTALL:
|
49
|
-
|
50
|
-
sudo gem install nofxx-rspec_spinner
|
51
|
-
|
52
|
-
|
53
53
|
== LICENSE:
|
54
54
|
|
55
55
|
(The MIT License)
|
56
56
|
|
57
57
|
Based on the Advanced Progress Bar by Nicholas A. Evans
|
58
58
|
|
59
|
-
Copyright (c) 2008 Marcos Piccinini
|
59
|
+
Copyright (c) 2008 Marcos Piccinini
|
data/Rakefile
CHANGED
@@ -5,8 +5,8 @@ require File.dirname(__FILE__) + '/lib/rspec_spinner'
|
|
5
5
|
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
6
6
|
$hoe = Hoe.new('rspec_spinner', RspecSpinner::VERSION) do |p|
|
7
7
|
p.developer('Marcos Piccinini', 'x@nofxx.com')
|
8
|
-
p.summary = "
|
9
|
-
p.description = "
|
8
|
+
p.summary = "Extra formatters for Rspec"
|
9
|
+
p.description = "Extra formatters for Rspec"
|
10
10
|
p.url = "http://github.com/nofxx/postgis_adapter"
|
11
11
|
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
12
12
|
p.post_install_message = 'PostInstall.txt'
|
data/lib/rspec_spinner/base.rb
CHANGED
@@ -13,12 +13,10 @@ module RspecSpinner
|
|
13
13
|
|
14
14
|
def start(example_count)
|
15
15
|
@current = 0
|
16
|
-
# @subject = "oi"
|
17
16
|
@total = example_count
|
18
17
|
@error_state = :all_passing
|
19
18
|
@pbar = Rtui::Progress.new("#{example_count} examples", example_count,
|
20
19
|
{:out => output, :components => [:percentage, :spinner, :stat]})
|
21
|
-
@pbar.subject = "Starting..."
|
22
20
|
end
|
23
21
|
|
24
22
|
def example_started(example)
|
@@ -35,7 +33,8 @@ module RspecSpinner
|
|
35
33
|
|
36
34
|
# third param is optional, because earlier versions of rspec sent only two args
|
37
35
|
def example_pending(example, message, pending_caller=nil)
|
38
|
-
|
36
|
+
desc = example.respond_to?(:full_description) ? example.full_description : example.description
|
37
|
+
immediately_dump_pending(desc, message, pending_caller)
|
39
38
|
mark_error_state_pending
|
40
39
|
increment
|
41
40
|
end
|
@@ -47,10 +46,6 @@ module RspecSpinner
|
|
47
46
|
end
|
48
47
|
|
49
48
|
def start_dump
|
50
|
-
@pbar.subject = ""
|
51
|
-
with_color do
|
52
|
-
@pbar.finish
|
53
|
-
end
|
54
49
|
output.flush
|
55
50
|
end
|
56
51
|
|
@@ -76,7 +71,8 @@ module RspecSpinner
|
|
76
71
|
def immediately_dump_pending(desc, msg, called_from)
|
77
72
|
erase_current_line
|
78
73
|
output.puts yellow("PENDING SPEC:") + " #{desc} (#{msg})"
|
79
|
-
output.puts " Called from #{called_from}" if called_from
|
74
|
+
output.puts format_backtrace(" Called from #{called_from}") if called_from
|
75
|
+
output.puts
|
80
76
|
end
|
81
77
|
|
82
78
|
def increment
|
@@ -86,7 +82,6 @@ module RspecSpinner
|
|
86
82
|
@pbar.instance_variable_set("@previous", 0)
|
87
83
|
@pbar.instance_variable_set("@title", "#{current}/#{total}")
|
88
84
|
@pbar.inc
|
89
|
-
# @pbar.subject = @subject if @subject
|
90
85
|
end
|
91
86
|
output.flush
|
92
87
|
end
|
@@ -95,6 +90,7 @@ module RspecSpinner
|
|
95
90
|
:all_passing => "\e[32m", # green
|
96
91
|
:some_pending => "\e[33m", # yellow
|
97
92
|
:some_failed => "\e[31m", # red
|
93
|
+
:pending_fix => "\e[34m", # blue
|
98
94
|
}
|
99
95
|
|
100
96
|
def with_color
|
@@ -1,18 +1,20 @@
|
|
1
1
|
module RspecSpinner
|
2
2
|
class Spinner < RspecSpinnerBase
|
3
3
|
|
4
|
-
|
5
4
|
def start(example_count)
|
6
5
|
@current = 0
|
7
6
|
@total = example_count
|
8
7
|
@error_state = :all_passing
|
9
8
|
@pbar = Rtui::Progress.new("#{example_count} examples", example_count,
|
10
9
|
{:out => output, :components => [:percentage, :spinner, :subject, :stat]})
|
10
|
+
@pbar.subject = "Starting..."
|
11
11
|
end
|
12
12
|
|
13
13
|
def example_started(example)
|
14
|
-
|
14
|
+
desc = example.description.gsub(/\r|\n/, "")
|
15
|
+
@pbar.subject = desc
|
15
16
|
super
|
16
17
|
end
|
18
|
+
|
17
19
|
end
|
18
20
|
end
|
data/lib/rspec_spinner.rb
CHANGED
data/rspec_spinner.gemspec
CHANGED
@@ -2,15 +2,15 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{rspec_spinner}
|
5
|
-
s.version = "0.
|
5
|
+
s.version = "0.5.1"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Marcos Piccinini"]
|
9
|
-
s.date = %q{
|
10
|
-
s.description = %q{
|
9
|
+
s.date = %q{2009-01-10}
|
10
|
+
s.description = %q{Extra formatters for Rspec}
|
11
11
|
s.email = ["x@nofxx.com"]
|
12
12
|
s.extra_rdoc_files = ["History.txt", "Manifest.txt", "PostInstall.txt", "README.rdoc"]
|
13
|
-
s.files = ["History.txt", "MIT-LICENSE", "Manifest.txt", "PostInstall.txt", "README.rdoc", "Rakefile", "lib/rspec_spinner.rb", "lib/rspec_spinner/bar.rb", "lib/rspec_spinner/base.rb", "lib/rspec_spinner/spinner.rb", "rspec_spinner.gemspec", "script/console", "script/destroy", "script/generate", "spec/rspec_spinner_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "tasks/rspec.rake"]
|
13
|
+
s.files = ["History.txt", "MIT-LICENSE", "Manifest.txt", "PostInstall.txt", "README.rdoc", "Rakefile", "lib/rspec_spinner.rb", "lib/rspec_spinner/bar.rb", "lib/rspec_spinner/base.rb", "lib/rspec_spinner/spinner.rb", "rspec_spinner.gemspec", "script/console", "script/destroy", "script/generate", "spec/rspec_spinner/base_spec.rb", "spec/rspec_spinner/spinner_spec.rb", "spec/rspec_spinner_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "tasks/rspec.rake"]
|
14
14
|
s.has_rdoc = true
|
15
15
|
s.homepage = %q{http://github.com/nofxx/postgis_adapter}
|
16
16
|
s.post_install_message = %q{PostInstall.txt}
|
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.require_paths = ["lib"]
|
19
19
|
s.rubyforge_project = %q{rspec_spinner}
|
20
20
|
s.rubygems_version = %q{1.3.1}
|
21
|
-
s.summary = %q{
|
21
|
+
s.summary = %q{Extra formatters for Rspec}
|
22
22
|
|
23
23
|
if s.respond_to? :specification_version then
|
24
24
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
@@ -27,18 +27,18 @@ Gem::Specification.new do |s|
|
|
27
27
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
28
28
|
s.add_runtime_dependency(%q<rspec>, [">= 1.1.11"])
|
29
29
|
s.add_runtime_dependency(%q<rtui>, [">= 0.1.8"])
|
30
|
-
s.add_development_dependency(%q<newgem>, [">= 1.2.
|
30
|
+
s.add_development_dependency(%q<newgem>, [">= 1.2.3"])
|
31
31
|
s.add_development_dependency(%q<hoe>, [">= 1.8.0"])
|
32
32
|
else
|
33
33
|
s.add_dependency(%q<rspec>, [">= 1.1.11"])
|
34
34
|
s.add_dependency(%q<rtui>, [">= 0.1.8"])
|
35
|
-
s.add_dependency(%q<newgem>, [">= 1.2.
|
35
|
+
s.add_dependency(%q<newgem>, [">= 1.2.3"])
|
36
36
|
s.add_dependency(%q<hoe>, [">= 1.8.0"])
|
37
37
|
end
|
38
38
|
else
|
39
39
|
s.add_dependency(%q<rspec>, [">= 1.1.11"])
|
40
40
|
s.add_dependency(%q<rtui>, [">= 0.1.8"])
|
41
|
-
s.add_dependency(%q<newgem>, [">= 1.2.
|
41
|
+
s.add_dependency(%q<newgem>, [">= 1.2.3"])
|
42
42
|
s.add_dependency(%q<hoe>, [">= 1.8.0"])
|
43
43
|
end
|
44
44
|
end
|
@@ -0,0 +1,117 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper.rb'
|
2
|
+
|
3
|
+
describe "Base" do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
@io = StringIO.new
|
7
|
+
@options = mock('options')
|
8
|
+
@options.stub!(:dry_run).and_return(false)
|
9
|
+
@options.stub!(:colour).and_return(false)
|
10
|
+
@formatter = RspecSpinner::Bar.new(@options, @io)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should produce line break on start dump" do
|
14
|
+
@formatter.start_dump
|
15
|
+
@io.string.should eql("")
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should produce standard summary without pending when pending has a 0 count" do
|
19
|
+
@formatter.dump_summary(3, 2, 1, 0)
|
20
|
+
@io.string.should eql("\nFinished in 3 seconds\n\n2 examples, 1 failure\n")
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "Examples" do
|
24
|
+
|
25
|
+
before(:all) do
|
26
|
+
class PassingGroup; end
|
27
|
+
class PendingGroup; end
|
28
|
+
@passing_group = PassingGroup.describe("passing_group") do
|
29
|
+
specify "passing" do
|
30
|
+
true.should be_true
|
31
|
+
end
|
32
|
+
end
|
33
|
+
@pending_group = PendingGroup.describe("pending_group") do
|
34
|
+
specify "pending" do
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should produce standard summary" do
|
40
|
+
example = @pending_group.examples.first
|
41
|
+
@formatter.start(1)
|
42
|
+
@formatter.example_pending(example, "message", "file/here:35")
|
43
|
+
@io.rewind
|
44
|
+
@formatter.dump_summary(3, 2, 1, 1)
|
45
|
+
@io.string.should eql("\nFinished in 3 seconds\n\n2 examples, 1 failure, 1 pending\n \r1 examples: 0% | | ETA: --:--:--\r\e[KPENDING SPEC: pending (message)\n Called from file/here:35:\n\n1/1: 100% |====================================================| ETA: 00:00:00\r")
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should update status and go green for passing spec" do
|
49
|
+
pending
|
50
|
+
@example = mock("Example", :description => "Foo") #@passing_group.examples.first
|
51
|
+
@io.should_receive(:tty?).and_return(true)
|
52
|
+
@options.should_receive(:colour).and_return(true)
|
53
|
+
@formatter.start(1)
|
54
|
+
#@formatter.example_started(example)
|
55
|
+
@formatter.example_passed(@example)
|
56
|
+
@io.string.should == "\e[32m.\e[0m"
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should output failure spec immediately (in red)" do
|
60
|
+
@io.should_receive(:tty?).and_return(true)
|
61
|
+
@options.should_receive(:colour).and_return(true)
|
62
|
+
@formatter.start(1)
|
63
|
+
@mock_fail = mock("Fail", :__full_description => "Very Failed")
|
64
|
+
@formatter.example_failed("spec", 98, Spec::Runner::Reporter::Failure.new(@mock_fail, Spec::Expectations::ExpectationNotMetError.new))
|
65
|
+
@io.string.should eql("\r \r1 examples: 0% | | ETA: --:--:--\r\e[K\n98) \e[31m'Very Failed' FAILED\nSpec::Expectations::ExpectationNotMetError\e[0m\n\n\n1/1: 100% |====================================================| ETA: 00:00:00\r")
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should push magenta for error spec" do
|
69
|
+
@io.should_receive(:tty?).and_return(true)
|
70
|
+
@options.should_receive(:colour).and_return(true)
|
71
|
+
@formatter.start(1)
|
72
|
+
@mock_fail = mock("Fail", :__full_description => "Error Failed")
|
73
|
+
@formatter.example_failed("spec", 98, Spec::Runner::Reporter::Failure.new(@mock_fail, RuntimeError.new))
|
74
|
+
@io.string.should eql("\r \r1 examples: 0% | | ETA: --:--:--\r\e[K\n98) \e[35mRuntimeError in 'Error Failed'\nRuntimeError\e[0m\n\n\n1/1: 100% |====================================================| ETA: 00:00:00\r")
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should push blue for fixed pending spec" do
|
78
|
+
@io.should_receive(:tty?).and_return(true)
|
79
|
+
@options.should_receive(:colour).and_return(true)
|
80
|
+
@formatter.start(1)
|
81
|
+
@mock_fail = mock("Fail", :__full_description => "Pending Fixed")
|
82
|
+
@formatter.example_failed("spec", 98, Spec::Runner::Reporter::Failure.new(@mock_fail, Spec::Example::PendingExampleFixedError.new))
|
83
|
+
@io.string.should eql("\r \r1 examples: 0% | | ETA: --:--:--\r\e[K\n98) \e[34m'Pending Fixed' FIXED\nSpec::Example::PendingExampleFixedError\e[0m\n\n\n1/1: 100% |====================================================| ETA: 00:00:00\r")
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should push slow specs" do
|
87
|
+
pending
|
88
|
+
@io.should_receive(:tty?).and_return(true)
|
89
|
+
@options.should_receive(:colour).and_return(true)
|
90
|
+
@formatter.start(1)
|
91
|
+
@mock_slow = mock("Slow", :description => "Pending Fixed")
|
92
|
+
@formatter.example_started(@mock_slow)
|
93
|
+
@formatter.example_passed(@mock_slow)
|
94
|
+
@formatter.example_failed("spec", 98, Spec::Runner::Reporter::Failure.new(@mock_fail, Spec::Example::PendingExampleFixedError.new))
|
95
|
+
@io.string.should eql("\r \r1 examples: 0% | | ETA: --:--:--\r\e[K\n98) \e[34m'Pending Fixed' FIXED\nSpec::Example::PendingExampleFixedError\e[0m\n\n\n1/1: 100% |====================================================| ETA: 00:00:00\r")
|
96
|
+
end
|
97
|
+
|
98
|
+
it "should push some stuff on start" do
|
99
|
+
@formatter.start(4)
|
100
|
+
@io.string.should eql("\r \r4 examples: 0% | | ETA: --:--:--\r")
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should not dump anything on the end" do
|
104
|
+
@formatter.dump_failure.should be_nil
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should ignore method missing" do
|
108
|
+
@formatter.method_missing(:foo).should be_nil
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should erase current line" do
|
112
|
+
@formatter.erase_current_line
|
113
|
+
@io.string.should eql("\e[K")
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
117
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper.rb'
|
2
|
+
|
3
|
+
describe "Spinner" do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
class PassingGroup; end
|
7
|
+
@passing_group = PassingGroup.describe("passing_group") do
|
8
|
+
specify "passing" do
|
9
|
+
true.should be_true
|
10
|
+
end
|
11
|
+
end
|
12
|
+
@io = StringIO.new
|
13
|
+
@options = mock('options')
|
14
|
+
@options.stub!(:dry_run).and_return(false)
|
15
|
+
@options.stub!(:colour).and_return(false)
|
16
|
+
@formatter = RspecSpinner::Spinner.new(@options, @io)
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should print the description on the avaiable space" do
|
20
|
+
@mock_pbar = mock("ProgressBar")
|
21
|
+
Rtui::Progress.should_receive(:new).and_return(@mock_pbar)
|
22
|
+
@mock_pbar.should_receive("subject=").with("Starting...")
|
23
|
+
@formatter.start(1)
|
24
|
+
@mock_pbar.should_receive("subject=").with("passing")
|
25
|
+
@formatter.example_started(@passing_group.examples.first)
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
data/spec/rspec_spinner_spec.rb
CHANGED
@@ -1,11 +1,9 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
2
|
|
3
|
-
# Time to add your specs!
|
4
|
-
# http://rspec.info/
|
5
3
|
describe "Place your specs here" do
|
6
4
|
|
7
|
-
it "
|
8
|
-
|
5
|
+
it "should integrate better" do
|
6
|
+
pending
|
9
7
|
end
|
10
8
|
|
11
9
|
end
|
data/spec/spec.opts
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
--colour
|
1
|
+
--colour
|
2
|
+
--diff
|
data/spec/spec_helper.rb
CHANGED
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: 0.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcos Piccinini
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2009-01-10 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -37,7 +37,7 @@ dependencies:
|
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.2.
|
40
|
+
version: 1.2.3
|
41
41
|
version:
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: hoe
|
@@ -48,7 +48,7 @@ dependencies:
|
|
48
48
|
- !ruby/object:Gem::Version
|
49
49
|
version: 1.8.0
|
50
50
|
version:
|
51
|
-
description:
|
51
|
+
description: Extra formatters for Rspec
|
52
52
|
email:
|
53
53
|
- x@nofxx.com
|
54
54
|
executables: []
|
@@ -75,6 +75,8 @@ files:
|
|
75
75
|
- script/console
|
76
76
|
- script/destroy
|
77
77
|
- script/generate
|
78
|
+
- spec/rspec_spinner/base_spec.rb
|
79
|
+
- spec/rspec_spinner/spinner_spec.rb
|
78
80
|
- spec/rspec_spinner_spec.rb
|
79
81
|
- spec/spec.opts
|
80
82
|
- spec/spec_helper.rb
|
@@ -105,6 +107,6 @@ rubyforge_project: rspec_spinner
|
|
105
107
|
rubygems_version: 1.2.0
|
106
108
|
signing_key:
|
107
109
|
specification_version: 2
|
108
|
-
summary:
|
110
|
+
summary: Extra formatters for Rspec
|
109
111
|
test_files: []
|
110
112
|
|