fuubar 2.0.0.beta2 → 2.0.0.rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/fuubar.rb +25 -11
  3. data/spec/fuubar_spec.rb +27 -38
  4. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4f44685ac1981f569de28308e206e23686a6b3b9
4
- data.tar.gz: def73165132a4b1f3076f90d2e4a194b0f850900
3
+ metadata.gz: 0abf88de6fb0095bdb04fb5169ceaea6fa102694
4
+ data.tar.gz: 3953bf49610d3bc8a6761ed38504166345913ada
5
5
  SHA512:
6
- metadata.gz: 7f46d0747f7335758bec1ff6ff60c755e29b3d9ad18c05d6a068e098dae0ce8415e942f1dc53fa8fe298b6f278132f146e3fd6b8b84b157f98d65b482b14ebc4
7
- data.tar.gz: 44c714040f143bb1659581440e6d17b21782c08d023d12f6b429191e6312058b75401e9184683e347718b4511aba572ff19b6bbdc9ba01b5800f72b790a15238
6
+ metadata.gz: 98b9c655ebd6223fa135f437de49a02fc39575c80d2ed2aa6f939632090b94c2b212e15d72400166f122d633156eda809eb15da4004b4a8cee94d95bf8416697
7
+ data.tar.gz: 75d107b7738cbc371af239b45c9609e3be0a4606c3cff29f1cdd25144a66864fc2070c761b9b600e2e628b6a605f7f263a2f98bc7f2cebeba84e4218f159be62
@@ -1,5 +1,6 @@
1
1
  require 'rspec'
2
2
  require 'rspec/core/formatters/base_text_formatter'
3
+ require 'rspec/core/formatters/console_codes'
3
4
  require 'ruby-progressbar'
4
5
 
5
6
  RSpec.configuration.add_setting :fuubar_progress_bar_options, :default => {}
@@ -14,7 +15,10 @@ class Fuubar < RSpec::Core::Formatters::BaseTextFormatter
14
15
  :example_failed,
15
16
  :dump_failures
16
17
 
17
- attr_accessor :progress
18
+ attr_accessor :progress,
19
+ :passed_count,
20
+ :pending_count,
21
+ :failed_count
18
22
 
19
23
  def initialize(*args)
20
24
  super
@@ -34,7 +38,10 @@ class Fuubar < RSpec::Core::Formatters::BaseTextFormatter
34
38
  :output => output,
35
39
  :autostart => false)
36
40
 
37
- self.progress = ProgressBar.create(progress_bar_options)
41
+ self.progress = ProgressBar.create(progress_bar_options)
42
+ self.passed_count = 0
43
+ self.pending_count = 0
44
+ self.failed_count = 0
38
45
 
39
46
  super
40
47
 
@@ -42,24 +49,23 @@ class Fuubar < RSpec::Core::Formatters::BaseTextFormatter
42
49
  end
43
50
 
44
51
  def example_passed(notification)
52
+ self.passed_count += 1
53
+
45
54
  increment
46
55
  end
47
56
 
48
57
  def example_pending(notification)
49
- super
58
+ self.pending_count += 1
50
59
 
51
60
  increment
52
61
  end
53
62
 
54
63
  def example_failed(notification)
55
- super
64
+ self.failed_count += 1
56
65
 
57
- example = notification.example
58
66
  progress.clear
59
67
 
60
- dump_failure example, failed_examples.size - 1
61
- dump_backtrace example
62
-
68
+ output.puts notification.fully_formatted(failed_count)
63
69
  output.puts
64
70
 
65
71
  increment
@@ -93,19 +99,27 @@ class Fuubar < RSpec::Core::Formatters::BaseTextFormatter
93
99
  end
94
100
 
95
101
  def color_enabled?
96
- super && !continuous_integration?
102
+ configuration.color_enabled? && !continuous_integration?
97
103
  end
98
104
 
99
105
  def current_color
100
- if failed_examples.size > 0
106
+ if failed_count > 0
101
107
  configuration.failure_color
102
- elsif pending_examples.size > 0
108
+ elsif pending_count > 0
103
109
  configuration.pending_color
104
110
  else
105
111
  configuration.success_color
106
112
  end
107
113
  end
108
114
 
115
+ def color_code_for(*args)
116
+ RSpec::Core::Formatters::ConsoleCodes.console_code_for(*args)
117
+ end
118
+
119
+ def configuration
120
+ RSpec.configuration
121
+ end
122
+
109
123
  def continuous_integration?
110
124
  @continuous_integration ||= !(ENV['CONTINUOUS_INTEGRATION'].nil? || ENV['CONTINUOUS_INTEGRATION'] == '' || ENV['CONTINUOUS_INTEGRATION'] == 'false')
111
125
  end
@@ -12,14 +12,14 @@ describe Fuubar do
12
12
  io
13
13
  end
14
14
 
15
- let(:formatter) { Fuubar.new(output) }
16
- let(:example) { RSpec::Core::ExampleGroup.describe.example }
17
- let(:notification) { OpenStruct.new(count: 2,
18
- example: example,
19
- message: 'My Message') }
20
- let(:failed_notification) { OpenStruct.new(count: 2,
21
- example: failed_example,
22
- message: 'My Message') }
15
+ let(:formatter) { Fuubar.new(output) }
16
+ let(:example) { RSpec::Core::ExampleGroup.describe.example }
17
+ let(:example_count) { 2 }
18
+ let(:start_notification) { RSpec::Core::Notifications::StartNotification.new(example_count, Time.now) }
19
+ let(:message_notification) { RSpec::Core::Notifications::MessageNotification.new('My Message') }
20
+ let(:example_notification) { RSpec::Core::Notifications::ExampleNotification.for(example) }
21
+ let(:pending_notification) { RSpec::Core::Notifications::ExampleNotification.for(pending_example) }
22
+ let(:failed_notification) { RSpec::Core::Notifications::ExampleNotification.for(failed_example) }
23
23
 
24
24
  let(:failed_example) do
25
25
  exception = RuntimeError.new('Test Fuubar Error')
@@ -29,15 +29,19 @@ describe Fuubar do
29
29
 
30
30
  example = RSpec::Core::ExampleGroup.describe.example
31
31
 
32
- example.instance_variable_set(:@metadata, {
33
- :file_path => '/my/example/spec.rb',
34
- :execution_result => {
35
- :exception => exception },
36
- } )
32
+ example.metadata[:file_path] = '/my/example/spec.rb'
33
+ example.metadata[:execution_result].status = :failed
34
+ example.metadata[:execution_result].exception = exception
37
35
 
38
36
  example
39
37
  end
40
38
 
39
+ let(:pending_example) do
40
+ example = RSpec::Core::ExampleGroup.describe.example
41
+ example.metadata[:execution_result].pending_fixed = true
42
+ example
43
+ end
44
+
41
45
  let(:fuubar_results) do
42
46
  output.rewind
43
47
  output.read
@@ -56,7 +60,7 @@ describe Fuubar do
56
60
  it 'does not start the bar until the formatter is started' do
57
61
  expect(formatter.progress).not_to be_started
58
62
 
59
- formatter.start(notification)
63
+ formatter.start(start_notification)
60
64
 
61
65
  expect(formatter.progress).to be_started
62
66
  end
@@ -93,7 +97,7 @@ describe Fuubar do
93
97
 
94
98
  context 'when processing an example' do
95
99
  before do
96
- formatter.start(notification)
100
+ formatter.start(start_notification)
97
101
 
98
102
  throttle = formatter.progress.instance_variable_get(:@throttle)
99
103
  throttle_rate = throttle.instance_variable_set(:@period, 0.0)
@@ -124,7 +128,7 @@ describe Fuubar do
124
128
 
125
129
  context 'when processing an example' do
126
130
  before do
127
- formatter.start(notification)
131
+ formatter.start(start_notification)
128
132
 
129
133
  throttle = formatter.progress.instance_variable_get(:@throttle)
130
134
  throttle_rate = throttle.instance_variable_set(:@period, 0.0)
@@ -152,7 +156,7 @@ describe Fuubar do
152
156
  end
153
157
 
154
158
  context 'when the bar is started' do
155
- before(:each) { formatter.start(notification) }
159
+ before(:each) { formatter.start(start_notification) }
156
160
 
157
161
  it 'properly creates the bar' do
158
162
  expect(formatter.progress.instance_variable_get(:@format_string)).to eql '%c'
@@ -161,7 +165,7 @@ describe Fuubar do
161
165
  end
162
166
 
163
167
  context 'when it is started' do
164
- before { formatter.start(notification) }
168
+ before { formatter.start(start_notification) }
165
169
 
166
170
  it 'sets the total to the number of examples' do
167
171
  expect(formatter.progress.total).to eql 2
@@ -189,10 +193,11 @@ describe Fuubar do
189
193
  before do
190
194
  output.rewind
191
195
 
192
- formatter.example_pending(notification)
196
+ formatter.example_pending(pending_example)
193
197
  end
194
198
 
195
199
  it 'outputs the proper bar information' do
200
+ formatter.progress.increment
196
201
  expect(fuubar_results).to start_with "\e[33m 1/2 |== 50 ==> | ETA: 00:00:00 \r\e[0m"
197
202
  end
198
203
 
@@ -200,7 +205,7 @@ describe Fuubar do
200
205
  before do
201
206
  output.rewind
202
207
 
203
- formatter.example_pending(notification)
208
+ formatter.example_pending(pending_notification)
204
209
  end
205
210
 
206
211
  it 'outputs the pending bar' do
@@ -218,22 +223,6 @@ describe Fuubar do
218
223
  expect(fuubar_results).to end_with "\e[31m 1/2 |== 50 ==> | ETA: 00:00:00 \r\e[0m"
219
224
  end
220
225
 
221
- it 'dumps the failure' do
222
- allow(formatter).to receive(:dump_failure).
223
- and_return('dump failure')
224
-
225
- allow(formatter).to receive(:dump_backtrace).
226
- and_return('dump backtrace')
227
-
228
- formatter.example_failed(failed_notification)
229
-
230
- expect(formatter).to have_received(:dump_failure).
231
- with(failed_example, 0)
232
-
233
- expect(formatter).to have_received(:dump_backtrace).
234
- with(failed_example)
235
- end
236
-
237
226
  context 'and then an example succeeds' do
238
227
  before do
239
228
  formatter.example_failed(failed_notification)
@@ -254,7 +243,7 @@ describe Fuubar do
254
243
 
255
244
  output.rewind
256
245
 
257
- formatter.example_pending(notification)
246
+ formatter.example_pending(example_notification)
258
247
  end
259
248
 
260
249
  it 'outputs the failed bar' do
@@ -264,7 +253,7 @@ describe Fuubar do
264
253
  end
265
254
 
266
255
  it 'can properly log messages' do
267
- formatter.message notification
256
+ formatter.message message_notification
268
257
 
269
258
  expect(fuubar_results).to end_with "My Message\n 0/2 |> | ETA: ??:??:?? \r"
270
259
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fuubar
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.beta2
4
+ version: 2.0.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicholas Evans
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-05-11 00:00:00.000000000 Z
13
+ date: 2014-05-27 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec
@@ -18,14 +18,14 @@ dependencies:
18
18
  requirements:
19
19
  - - "~>"
20
20
  - !ruby/object:Gem::Version
21
- version: 3.0.beta
21
+ version: 3.0.rc1
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
26
  - - "~>"
27
27
  - !ruby/object:Gem::Version
28
- version: 3.0.beta
28
+ version: 3.0.rc1
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: ruby-progressbar
31
31
  requirement: !ruby/object:Gem::Requirement