fuubar 1.3.3 → 2.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +6 -4
- data/lib/fuubar.rb +18 -18
- data/spec/fuubar_spec.rb +37 -54
- metadata +26 -25
- checksums.yaml +0 -7
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
Fuubar
|
2
|
-
|
1
|
+
#Fuubar
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/fuubar.png)](https://badge.fury.io/rb/fuubar) [![Travis CI Status](https://travis-ci.org/jeffkreeftmeijer/fuubar.png)](https://travis-ci.org/jeffkreeftmeijer/fuubar) [![CodeClimate Badge](https://codeclimate.com/github/jeffkreeftmeijer/fuubar.png)](https://codeclimate.com/github/jeffkreeftmeijer/fuubar)
|
3
4
|
|
4
5
|
Fuubar is an instafailing [RSpec](http://github.com/rspec) formatter that uses a progress bar instead of a string of letters and dots as feedback. Here's [a video of Fuubar in action](http://vimeo.com/16845253).
|
5
6
|
|
@@ -9,6 +10,7 @@ Supported Rubies
|
|
9
10
|
* MRI Ruby 1.9.2
|
10
11
|
* MRI Ruby 1.9.3
|
11
12
|
* MRI Ruby 2.0.0
|
13
|
+
* MRI Ruby 2.1.0
|
12
14
|
* JRuby (in 1.8 compat mode)
|
13
15
|
* JRuby (in 1.9 compat mode)
|
14
16
|
|
@@ -18,13 +20,13 @@ Installation
|
|
18
20
|
First:
|
19
21
|
|
20
22
|
```ruby
|
21
|
-
gem install
|
23
|
+
gem install fuubar
|
22
24
|
```
|
23
25
|
|
24
26
|
or in your Gemfile
|
25
27
|
|
26
28
|
```ruby
|
27
|
-
gem '
|
29
|
+
gem 'fuubar'
|
28
30
|
```
|
29
31
|
|
30
32
|
Then, when running rspec:
|
data/lib/fuubar.rb
CHANGED
@@ -7,50 +7,50 @@ RSpec.configuration.add_setting :fuubar_progress_bar_options, :default => {}
|
|
7
7
|
class Fuubar < RSpec::Core::Formatters::BaseTextFormatter
|
8
8
|
DEFAULT_PROGRESS_BAR_OPTIONS = { :format => ' %c/%C |%w>%i| %e ' }
|
9
9
|
|
10
|
+
RSpec::Core::Formatters.register self, :start,
|
11
|
+
:message,
|
12
|
+
:example_passed,
|
13
|
+
:example_pending,
|
14
|
+
:example_failed,
|
15
|
+
:dump_failures
|
16
|
+
|
10
17
|
attr_accessor :progress
|
11
18
|
|
12
19
|
def initialize(*args)
|
13
20
|
super
|
14
21
|
|
15
|
-
self.progress = ProgressBar.create(DEFAULT_PROGRESS_BAR_OPTIONS.
|
16
|
-
merge(:throttle_rate => continuous_integration? ? 1.0 : nil).
|
17
|
-
merge(:total => example_count,
|
18
|
-
:output => output,
|
19
|
-
:autostart => false))
|
20
|
-
end
|
21
|
-
|
22
|
-
def start(example_count)
|
23
22
|
progress_bar_options = DEFAULT_PROGRESS_BAR_OPTIONS.
|
24
23
|
merge(:throttle_rate => continuous_integration? ? 1.0 : nil).
|
25
24
|
merge(configuration.fuubar_progress_bar_options).
|
26
|
-
merge(:total =>
|
25
|
+
merge(:total => 0,
|
27
26
|
:output => output,
|
28
27
|
:autostart => false)
|
29
28
|
|
30
29
|
self.progress = ProgressBar.create(progress_bar_options)
|
30
|
+
end
|
31
31
|
|
32
|
+
def start(notification)
|
32
33
|
super
|
33
34
|
|
34
|
-
progress.total =
|
35
|
+
progress.total = notification.count
|
35
36
|
|
36
37
|
with_current_color { progress.start }
|
37
38
|
end
|
38
39
|
|
39
|
-
def example_passed(
|
40
|
-
super
|
41
|
-
|
40
|
+
def example_passed(notification)
|
42
41
|
increment
|
43
42
|
end
|
44
43
|
|
45
|
-
def example_pending(
|
44
|
+
def example_pending(notification)
|
46
45
|
super
|
47
46
|
|
48
47
|
increment
|
49
48
|
end
|
50
49
|
|
51
|
-
def example_failed(
|
50
|
+
def example_failed(notification)
|
52
51
|
super
|
53
52
|
|
53
|
+
example = notification.example
|
54
54
|
progress.clear
|
55
55
|
|
56
56
|
dump_failure example, failed_examples.size - 1
|
@@ -61,15 +61,15 @@ class Fuubar < RSpec::Core::Formatters::BaseTextFormatter
|
|
61
61
|
increment
|
62
62
|
end
|
63
63
|
|
64
|
-
def message(
|
64
|
+
def message(notification)
|
65
65
|
if progress.respond_to? :log
|
66
|
-
progress.log(
|
66
|
+
progress.log(notification.message)
|
67
67
|
else
|
68
68
|
super
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
|
-
def dump_failures
|
72
|
+
def dump_failures(notification)
|
73
73
|
#
|
74
74
|
# We output each failure as it happens so we don't need to output them en
|
75
75
|
# masse at the end of the run.
|
data/spec/fuubar_spec.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'fuubar'
|
2
2
|
require 'stringio'
|
3
|
+
require 'ostruct'
|
3
4
|
|
4
5
|
describe Fuubar do
|
5
6
|
let(:output) do
|
@@ -11,8 +12,15 @@ describe Fuubar do
|
|
11
12
|
io
|
12
13
|
end
|
13
14
|
|
14
|
-
let(:formatter)
|
15
|
-
let(:
|
15
|
+
let(:formatter) { Fuubar.new(output) }
|
16
|
+
let(:progress) { formatter.instance_variable_get(:@progress) }
|
17
|
+
let(:example) { RSpec::Core::ExampleGroup.describe.example }
|
18
|
+
let(:notification) { OpenStruct.new(count: 2,
|
19
|
+
example: example,
|
20
|
+
message: 'My Message') }
|
21
|
+
let(:failed_notification) { OpenStruct.new(count: 2,
|
22
|
+
example: failed_example,
|
23
|
+
message: 'My Message') }
|
16
24
|
|
17
25
|
let(:failed_example) do
|
18
26
|
exception = RuntimeError.new('Test Fuubar Error')
|
@@ -47,28 +55,28 @@ describe Fuubar do
|
|
47
55
|
|
48
56
|
context 'when it is created' do
|
49
57
|
it 'does not start the bar until the formatter is started' do
|
50
|
-
expect(
|
58
|
+
expect(progress).not_to be_started
|
51
59
|
|
52
|
-
formatter.start(
|
60
|
+
formatter.start(notification)
|
53
61
|
|
54
|
-
expect(
|
62
|
+
expect(progress).to be_started
|
55
63
|
end
|
56
64
|
|
57
65
|
it 'creates a new ProgressBar' do
|
58
|
-
expect(
|
66
|
+
expect(progress).to be_instance_of ProgressBar::Base
|
59
67
|
end
|
60
68
|
|
61
|
-
it 'sets the format of the bar
|
62
|
-
expect(
|
69
|
+
it 'sets the format of the bar' do
|
70
|
+
expect(progress.instance_variable_get(:@format_string)).to eql ' %c/%C |%w>%i| %e '
|
63
71
|
end
|
64
72
|
|
65
73
|
it 'sets the total to the number of examples' do
|
66
|
-
expect(
|
74
|
+
expect(progress.total).to be_zero
|
67
75
|
end
|
68
76
|
|
69
77
|
it 'sets the bar\'s output' do
|
70
|
-
expect(
|
71
|
-
expect(
|
78
|
+
expect(progress.send(:output)).to eql formatter.output
|
79
|
+
expect(progress.send(:output)).to eql output
|
72
80
|
end
|
73
81
|
|
74
82
|
context 'and continuous integration is enabled' do
|
@@ -78,7 +86,7 @@ describe Fuubar do
|
|
78
86
|
end
|
79
87
|
|
80
88
|
it 'throttles the progress bar at one second' do
|
81
|
-
throttle =
|
89
|
+
throttle = progress.instance_variable_get(:@throttle)
|
82
90
|
throttle_rate = throttle.instance_variable_get(:@period)
|
83
91
|
|
84
92
|
expect(throttle_rate).to eql 1.0
|
@@ -86,11 +94,11 @@ describe Fuubar do
|
|
86
94
|
|
87
95
|
context 'when processing an example' do
|
88
96
|
before do
|
89
|
-
|
90
|
-
|
91
|
-
throttle = formatter.progress.instance_variable_get(:@throttle)
|
97
|
+
throttle = progress.instance_variable_get(:@throttle)
|
92
98
|
throttle_rate = throttle.instance_variable_set(:@period, 0.0)
|
93
99
|
|
100
|
+
formatter.start(notification)
|
101
|
+
|
94
102
|
output.rewind
|
95
103
|
|
96
104
|
formatter.example_passed(example)
|
@@ -109,7 +117,7 @@ describe Fuubar do
|
|
109
117
|
end
|
110
118
|
|
111
119
|
it 'throttles the progress bar at the default rate' do
|
112
|
-
throttle =
|
120
|
+
throttle = progress.instance_variable_get(:@throttle)
|
113
121
|
throttle_rate = throttle.instance_variable_get(:@period)
|
114
122
|
|
115
123
|
expect(throttle_rate).to eql 0.01
|
@@ -117,11 +125,11 @@ describe Fuubar do
|
|
117
125
|
|
118
126
|
context 'when processing an example' do
|
119
127
|
before do
|
120
|
-
|
121
|
-
|
122
|
-
throttle = formatter.progress.instance_variable_get(:@throttle)
|
128
|
+
throttle = progress.instance_variable_get(:@throttle)
|
123
129
|
throttle_rate = throttle.instance_variable_set(:@period, 0.0)
|
124
130
|
|
131
|
+
formatter.start(notification)
|
132
|
+
|
125
133
|
output.rewind
|
126
134
|
|
127
135
|
formatter.example_passed(example)
|
@@ -134,36 +142,11 @@ describe Fuubar do
|
|
134
142
|
end
|
135
143
|
end
|
136
144
|
|
137
|
-
context 'when custom options are set after the formatter is created' do
|
138
|
-
before(:each) do
|
139
|
-
formatter
|
140
|
-
RSpec.configuration.fuubar_progress_bar_options = {
|
141
|
-
:length => 40,
|
142
|
-
:throttle_rate => 0.0,
|
143
|
-
:format => '%c',
|
144
|
-
}
|
145
|
-
end
|
146
|
-
|
147
|
-
context 'when the bar is started' do
|
148
|
-
before(:each) { formatter.start(2) }
|
149
|
-
|
150
|
-
it 'properly creates the bar' do
|
151
|
-
expect(formatter.progress.instance_variable_get(:@format_string)).to eql '%c'
|
152
|
-
end
|
153
|
-
end
|
154
|
-
end
|
155
|
-
|
156
145
|
context 'when it is started' do
|
157
|
-
before { formatter.start(
|
146
|
+
before { formatter.start(notification) }
|
158
147
|
|
159
148
|
it 'sets the total to the number of examples' do
|
160
|
-
expect(
|
161
|
-
end
|
162
|
-
|
163
|
-
context 'and no custom options are passed in' do
|
164
|
-
it 'sets the format of the bar to the default' do
|
165
|
-
expect(formatter.progress.instance_variable_get(:@format_string)).to eql ' %c/%C |%w>%i| %e '
|
166
|
-
end
|
149
|
+
expect(progress.total).to eql 2
|
167
150
|
end
|
168
151
|
|
169
152
|
context 'and an example passes' do
|
@@ -182,7 +165,7 @@ describe Fuubar do
|
|
182
165
|
before do
|
183
166
|
output.rewind
|
184
167
|
|
185
|
-
formatter.example_pending(
|
168
|
+
formatter.example_pending(notification)
|
186
169
|
end
|
187
170
|
|
188
171
|
it 'outputs the proper bar information' do
|
@@ -193,7 +176,7 @@ describe Fuubar do
|
|
193
176
|
before do
|
194
177
|
output.rewind
|
195
178
|
|
196
|
-
formatter.example_pending(
|
179
|
+
formatter.example_pending(notification)
|
197
180
|
end
|
198
181
|
|
199
182
|
it 'outputs the pending bar' do
|
@@ -206,7 +189,7 @@ describe Fuubar do
|
|
206
189
|
it 'outputs the proper bar information' do
|
207
190
|
output.rewind
|
208
191
|
|
209
|
-
formatter.example_failed(
|
192
|
+
formatter.example_failed(failed_notification)
|
210
193
|
|
211
194
|
expect(fuubar_results).to end_with "\e[31m 1/2 |== 50 ==> | ETA: 00:00:00 \r\e[0m"
|
212
195
|
end
|
@@ -218,7 +201,7 @@ describe Fuubar do
|
|
218
201
|
allow(formatter).to receive(:dump_backtrace).
|
219
202
|
and_return('dump backtrace')
|
220
203
|
|
221
|
-
formatter.example_failed(
|
204
|
+
formatter.example_failed(failed_notification)
|
222
205
|
|
223
206
|
expect(formatter).to have_received(:dump_failure).
|
224
207
|
with(failed_example, 0)
|
@@ -229,7 +212,7 @@ describe Fuubar do
|
|
229
212
|
|
230
213
|
context 'and then an example succeeds' do
|
231
214
|
before do
|
232
|
-
formatter.example_failed(
|
215
|
+
formatter.example_failed(failed_notification)
|
233
216
|
|
234
217
|
output.rewind
|
235
218
|
|
@@ -243,11 +226,11 @@ describe Fuubar do
|
|
243
226
|
|
244
227
|
context 'and then an example pends' do
|
245
228
|
before do
|
246
|
-
formatter.example_failed(
|
229
|
+
formatter.example_failed(failed_notification)
|
247
230
|
|
248
231
|
output.rewind
|
249
232
|
|
250
|
-
formatter.example_pending(
|
233
|
+
formatter.example_pending(notification)
|
251
234
|
end
|
252
235
|
|
253
236
|
it 'outputs the failed bar' do
|
@@ -257,7 +240,7 @@ describe Fuubar do
|
|
257
240
|
end
|
258
241
|
|
259
242
|
it 'can properly log messages' do
|
260
|
-
formatter.message
|
243
|
+
formatter.message notification
|
261
244
|
|
262
245
|
expect(fuubar_results).to end_with "My Message\n 0/2 |> | ETA: ??:??:?? \r"
|
263
246
|
end
|
metadata
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fuubar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0.beta1
|
5
|
+
prerelease: 6
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Nicholas Evans
|
@@ -10,42 +11,40 @@ authors:
|
|
10
11
|
autorequire:
|
11
12
|
bindir: bin
|
12
13
|
cert_chain: []
|
13
|
-
date: 2014-
|
14
|
+
date: 2014-03-01 00:00:00.000000000 Z
|
14
15
|
dependencies:
|
15
16
|
- !ruby/object:Gem::Dependency
|
16
17
|
name: rspec
|
17
18
|
requirement: !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
18
20
|
requirements:
|
19
|
-
- -
|
21
|
+
- - ~>
|
20
22
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
22
|
-
- - "<"
|
23
|
-
- !ruby/object:Gem::Version
|
24
|
-
version: 3.1.0
|
23
|
+
version: 3.0.beta
|
25
24
|
type: :runtime
|
26
25
|
prerelease: false
|
27
26
|
version_requirements: !ruby/object:Gem::Requirement
|
27
|
+
none: false
|
28
28
|
requirements:
|
29
|
-
- -
|
30
|
-
- !ruby/object:Gem::Version
|
31
|
-
version: 2.14.0
|
32
|
-
- - "<"
|
29
|
+
- - ~>
|
33
30
|
- !ruby/object:Gem::Version
|
34
|
-
version: 3.
|
31
|
+
version: 3.0.beta
|
35
32
|
- !ruby/object:Gem::Dependency
|
36
33
|
name: ruby-progressbar
|
37
34
|
requirement: !ruby/object:Gem::Requirement
|
35
|
+
none: false
|
38
36
|
requirements:
|
39
|
-
- -
|
37
|
+
- - ~>
|
40
38
|
- !ruby/object:Gem::Version
|
41
|
-
version: '1.
|
39
|
+
version: '1.3'
|
42
40
|
type: :runtime
|
43
41
|
prerelease: false
|
44
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
45
44
|
requirements:
|
46
|
-
- -
|
45
|
+
- - ~>
|
47
46
|
- !ruby/object:Gem::Version
|
48
|
-
version: '1.
|
47
|
+
version: '1.3'
|
49
48
|
description: the instafailing RSpec progress bar formatter
|
50
49
|
email:
|
51
50
|
- jeff@kreeftmeijer.nl
|
@@ -55,34 +54,36 @@ extra_rdoc_files:
|
|
55
54
|
- README.md
|
56
55
|
- LICENSE
|
57
56
|
files:
|
58
|
-
- LICENSE
|
59
|
-
- README.md
|
60
57
|
- lib/fuubar.rb
|
58
|
+
- README.md
|
59
|
+
- LICENSE
|
61
60
|
- spec/fuubar_spec.rb
|
62
61
|
homepage: https://github.com/jeffkreeftmeijer/fuubar
|
63
62
|
licenses: []
|
64
|
-
metadata: {}
|
65
63
|
post_install_message:
|
66
64
|
rdoc_options:
|
67
|
-
-
|
65
|
+
- --charset
|
68
66
|
- UTF-8
|
69
67
|
require_paths:
|
70
68
|
- lib
|
71
69
|
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
72
71
|
requirements:
|
73
|
-
- -
|
72
|
+
- - ! '>='
|
74
73
|
- !ruby/object:Gem::Version
|
75
74
|
version: '0'
|
76
75
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
+
none: false
|
77
77
|
requirements:
|
78
|
-
- -
|
78
|
+
- - ! '>'
|
79
79
|
- !ruby/object:Gem::Version
|
80
|
-
version:
|
80
|
+
version: 1.3.1
|
81
81
|
requirements: []
|
82
82
|
rubyforge_project: fuubar
|
83
|
-
rubygems_version:
|
83
|
+
rubygems_version: 1.8.23
|
84
84
|
signing_key:
|
85
|
-
specification_version:
|
85
|
+
specification_version: 3
|
86
86
|
summary: the instafailing RSpec progress bar formatter
|
87
87
|
test_files:
|
88
88
|
- spec/fuubar_spec.rb
|
89
|
+
has_rdoc:
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: 0abed866500f12dc809a3058b70b72d0acabbf4f
|
4
|
-
data.tar.gz: ef1c62fed7ecb780e495751517159409d80ca9e3
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: 5cc7b582ed5a19df4448293638305019cd660a9f9371686486adcb94a11dfc01da63876aa553b1b43151bd8bde0db07a87a917189b0b64b327b2807cf91ea136
|
7
|
-
data.tar.gz: 5ac7935063d2a7a8434eb5c34a6141773d160e2f5cb5322123265764eb238863eaaa75fe47bbccd5147ed4623667fb04394ae89dffa31850455717870a4381cc
|