rspec-fuubar 1.0.0

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 (6) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +19 -0
  3. data/README.md +224 -0
  4. data/lib/fuubar.rb +5 -0
  5. data/lib/rspec/fuubar.rb +147 -0
  6. metadata +112 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 04bfd7327af20d94156d340dcb5a270ddaf077ff6e87f042d2a661458e976346
4
+ data.tar.gz: 46e785e54befce76f3ea61d5c3ee766dd2e9eea97c4a7a934365622939509f63
5
+ SHA512:
6
+ metadata.gz: 38ecff3bd3530f922d85b7802c9add7694657d804c3e13304f277c7431924395470dd1d12d8210a06d2f673cfa3709058b3cb93b650c677c7a5e00603f4b6a85
7
+ data.tar.gz: 68d792dae5e54aec07617e37becf32f0be6d6bf9cc7b0a847d9fa322b637e87939a5c23f7dd47ab856bb2510da5b7d2b059321dbd7e739a916c786c2fdd44cb2
data/LICENSE.txt ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2010-2019 The Kompanee, Ltd
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,224 @@
1
+ Fuubar
2
+ ================================================================================
3
+
4
+ <div align="center">
5
+ <a href="https://rubygems.org/gems/fuubar" alt="RubyGems Version">
6
+ <img src="https://img.shields.io/gem/v/fuubar.svg?style=flat-square&label=current-version" alt="RubyGems Version" />
7
+ </a>
8
+
9
+ <a href="https://rubygems.org/gems/fuubar" alt="RubyGems Rank Overall">
10
+ <img src="https://img.shields.io/gem/rt/fuubar.svg?style=flat-square&label=total-rank" alt="RubyGems Rank Overall" />
11
+ </a>
12
+
13
+ <a href="https://rubygems.org/gems/fuubar" alt="RubyGems Rank Daily">
14
+ <img src="https://img.shields.io/gem/rd/fuubar.svg?style=flat-square&label=daily-rank" alt="RubyGems Rank Daily" />
15
+ </a>
16
+
17
+ <a href="https://rubygems.org/gems/fuubar" alt="RubyGems Downloads">
18
+ <img src="https://img.shields.io/gem/dt/fuubar.svg?style=flat-square&label=total-downloads" alt="RubyGems Downloads" />
19
+ </a>
20
+
21
+ <a href="https://github.com/thekompanee/fuubar/actions?query=workflow%3ABuild" alt="Build Status">
22
+ <img src="https://img.shields.io/github/workflow/status/jfelchner/fuubar/Build?label=CI&style=flat-square&logo=github" alt="Build Status" />
23
+ </a>
24
+ </div>
25
+
26
+ <br>
27
+
28
+ fuubar is an instafailing [RSpec][rspec] formatter that uses
29
+ a progress bar instead of a string of letters and dots as feedback.
30
+
31
+ ![examples][example-gif]
32
+
33
+ Installation
34
+ --------------------------------------------------------------------------------
35
+
36
+ ```ruby
37
+ gem install fuubar
38
+
39
+ # or in your Gemfile
40
+
41
+ gem 'fuubar'
42
+ ```
43
+
44
+ Usage
45
+ --------------------------------------------------------------------------------
46
+
47
+ In order to use fuubar, you have three options.
48
+
49
+ ### Option 1: Invoke It Manually Via The Command Line
50
+
51
+ ```bash
52
+ rspec --format Fuubar --color
53
+ ```
54
+
55
+ ### Option 2: Add It To Your Local `.rspec` File
56
+
57
+ ```text
58
+ # .rspec
59
+
60
+ --format Fuubar
61
+ --color
62
+ ```
63
+
64
+ ### Option 3: Add It To Your `spec_helper.rb`
65
+
66
+ ```ruby
67
+ # spec/spec_helper.rb
68
+
69
+ RSpec.configure do |config|
70
+ config.add_formatter 'Fuubar'
71
+ end
72
+ ```
73
+
74
+ Advanced Usage
75
+ --------------------------------
76
+
77
+ ### Customizing The Bar
78
+
79
+ fuubar exposes an RSpec configuration variable called
80
+ `fuubar_progress_bar_options` which, when set will be passed directly to
81
+ [ruby-progressbar][rpb-github] which does all the heavy lifting. Take a look at
82
+ the [ruby-progressbar documentation][rpb-docs] for details on all of the options
83
+ you can pass in.
84
+
85
+ #### Example
86
+
87
+ Let's say for example that you would like to change the format of the bar. You
88
+ would do that like so:
89
+
90
+ ```ruby
91
+ # spec/spec_helper.rb
92
+
93
+ RSpec.configure do |config|
94
+ config.fuubar_progress_bar_options = { :format => 'My Fuubar! <%B> %p%% %a' }
95
+ end
96
+ ```
97
+
98
+ would make it so that, when fuubar is output, it would look something like:
99
+
100
+ ```text
101
+ My Fuubar! <================================ > 53.44% 00:12:31
102
+ ```
103
+
104
+ ### Hiding Pending/Skipped Spec Summary
105
+
106
+ By default fuubar follows RSpec's lead and will dump out a summary of all of the
107
+ pending specs in the suite once the test run is over. This is a good idea
108
+ because the additional noise is a nudge to fix those tests. We realize however
109
+ that not all teams have the luxury of implementing all of the pending specs and
110
+ therefore fuubar gives you the option of supressing that summary.
111
+
112
+ #### Example
113
+
114
+ ```ruby
115
+ # spec/spec_helper.rb
116
+
117
+ RSpec.configure do |config|
118
+ config.fuubar_output_pending_results = false
119
+ end
120
+ ```
121
+
122
+ ### Enabling Auto-Refresh
123
+
124
+ By default fuubar refreshes the bar only between each spec.
125
+ You can enable an auto-refresh feature that will keep refreshing the bar (and
126
+ therefore the ETA) every second.
127
+ You can enable the feature as follows:
128
+
129
+ ```ruby
130
+ # spec/spec_helper.rb
131
+
132
+ RSpec.configure do |config|
133
+ config.fuubar_auto_refresh = true
134
+ end
135
+ ```
136
+
137
+ #### Undesirable Effects
138
+
139
+ Unfortunately this option doesn't play well with things like debuggers, as
140
+ having a bar show up every second would be undesireable (which is why the
141
+ feature is disabled by default). Depending on what you are using, you may be
142
+ given ways to work around this problem.
143
+
144
+ ##### Pry
145
+
146
+ [Pry][pry] provides hooks that can be used to disable fuubar during a debugging
147
+ session, you could for example add the following to your spec helper:
148
+
149
+ ```ruby
150
+ # spec/spec_helper.rb
151
+
152
+ Pry.config.hooks.add_hook(:before_session, :disable_fuubar_auto_refresh) do |_output, _binding, _pry|
153
+ RSpec.configuration.fuubar_auto_refresh = false
154
+ end
155
+
156
+ Pry.config.hooks.add_hook(:after_session, :restore_fuubar_auto_refresh) do |_output, _binding, _pry|
157
+ RSpec.configuration.fuubar_auto_refresh = true
158
+ end
159
+ ```
160
+
161
+ ##### Byebug
162
+
163
+ Unfortunately [byebug][byebug] does not provide hooks, so your best bet is to
164
+ disable auto-refresh manually before calling `byebug`.
165
+
166
+ ```ruby
167
+ RSpec.configuration.fuubar_auto_refresh = false
168
+ byebug
169
+ ```
170
+
171
+ Security
172
+ --------------------------------------------------------------------------------
173
+
174
+ fuubar is cryptographically signed. To be sure the gem you install hasn’t been
175
+ tampered with, follow these steps:
176
+
177
+ * Add my public key (if you haven’t already) as a trusted certificate
178
+
179
+ ```bash
180
+ gem cert --add <(curl -Ls https://raw.github.com/thekompanee/fuubar/master/certs/thekompanee.pem)
181
+ ```
182
+
183
+ * Install fuubar telling it to use security checks when possible.
184
+
185
+ ```bash
186
+ gem install fuubar -P MediumSecurity
187
+ ```
188
+
189
+ > **Note:** The `MediumSecurity` trust profile will verify signed gems, but
190
+ > allow the installation of unsigned dependencies.
191
+ >
192
+ > This is necessary because fuubar has a dependency on RSpec which isn't signed,
193
+ > and therefore we cannot use `HighSecurity`, which requires signed gems.
194
+
195
+ Credits
196
+ --------------------------------------------------------------------------------
197
+
198
+ fuubar was written by [Jeff Felchner][jefff-profile] and [Jeff
199
+ Kreeftmeijer][jeffk-profile]
200
+
201
+ ![The Kompanee][kompanee-logo]
202
+
203
+ fuubar is maintained and funded by [The Kompanee, Ltd.][kompanee-site]
204
+
205
+ The names and logos for The Kompanee are trademarks of The Kompanee, Ltd.
206
+
207
+ License
208
+ --------------------------------------------------------------------------------
209
+
210
+ fuubar is Copyright &copy; 2010-2021 Jeff Kreeftmeijer and Jeff Felchner. It is
211
+ free software, and may be redistributed under the terms specified in the
212
+ [LICENSE][license] file.
213
+
214
+ [byebug]: https://github.com/deivid-rodriguez/byebug
215
+ [example-gif]: https://kompanee-public-assets.s3.amazonaws.com/readmes/fuubar-examples.gif
216
+ [jefff-profile]: https://github.com/jfelchner
217
+ [jeffk-profile]: https://github.com/jeffkreeftmeijer
218
+ [kompanee-logo]: https://kompanee-public-assets.s3.amazonaws.com/readmes/kompanee-horizontal-black.png
219
+ [kompanee-site]: http://www.thekompanee.com
220
+ [license]: https://github.com/thekompanee/fuubar/blob/master/LICENSE.txt
221
+ [pry]: https://github.com/pry/pry
222
+ [rpb-docs]: https://github.com/jfelchner/ruby-progressbar/wiki/Options
223
+ [rpb-github]: https://github.com/jfelchner/ruby-progressbar
224
+ [rspec]: https://github.com/rspec
data/lib/fuubar.rb ADDED
@@ -0,0 +1,5 @@
1
+ # Backward compatibility - require the new location
2
+ require "rspec/fuubar"
3
+
4
+ # Alias at top level for backward compatibility
5
+ Fuubar = RSpec::Fuubar
@@ -0,0 +1,147 @@
1
+ require "rspec/core"
2
+ require "rspec/core/formatters/base_formatter"
3
+ require "ruby-progressbar"
4
+
5
+ RSpec.configuration.add_setting :fuubar_progress_bar_options, default: {}
6
+ RSpec.configuration.add_setting :fuubar_auto_refresh, default: false
7
+ RSpec.configuration.add_setting :fuubar_output_pending_results, default: true
8
+
9
+ module RSpec
10
+ class Fuubar < Core::Formatters::BaseFormatter
11
+ Core::Formatters.register self,
12
+ :start,
13
+ :example_passed,
14
+ :example_failed,
15
+ :example_pending,
16
+ :message,
17
+ :dump_pending,
18
+ :dump_failures,
19
+ :dump_summary,
20
+ :seed,
21
+ :close
22
+
23
+ DEFAULT_PROGRESS_BAR_OPTIONS = { format: " %c/%C |%w>%i| %e " }.freeze
24
+
25
+ attr_reader :progress, :passed_count, :pending_count, :failed_count
26
+
27
+ def initialize(output)
28
+ super
29
+ @passed_count = 0
30
+ @pending_count = 0
31
+ @failed_count = 0
32
+ end
33
+
34
+ def start(notification)
35
+ @passed_count = 0
36
+ @pending_count = 0
37
+ @failed_count = 0
38
+
39
+ progress_options = DEFAULT_PROGRESS_BAR_OPTIONS
40
+ .merge(throttle_rate: continuous_integration? ? 1.0 : nil)
41
+ .merge(RSpec.configuration.fuubar_progress_bar_options)
42
+ .merge(total: notification.count,
43
+ output:,
44
+ autostart: false)
45
+
46
+ @progress = ProgressBar.create(progress_options)
47
+
48
+ with_current_color { @progress.start }
49
+ end
50
+
51
+ def example_passed(_notification)
52
+ @passed_count += 1
53
+ increment
54
+ end
55
+
56
+ def example_pending(_notification)
57
+ @pending_count += 1
58
+ increment
59
+ end
60
+
61
+ def example_failed(notification)
62
+ @failed_count += 1
63
+
64
+ # Clear progress bar and output failure immediately
65
+ @progress&.clear
66
+
67
+ output.puts
68
+ output.puts notification.fully_formatted(@failed_count)
69
+ output.puts
70
+
71
+ increment
72
+ end
73
+
74
+ def message(notification)
75
+ if @progress.respond_to?(:log)
76
+ @progress.log(notification.message)
77
+ else
78
+ output.puts notification.message
79
+ end
80
+ end
81
+
82
+ def dump_pending(notification)
83
+ return unless RSpec.configuration.fuubar_output_pending_results
84
+ return if notification.pending_examples.empty?
85
+
86
+ output.puts
87
+ output.puts notification.fully_formatted_pending_examples
88
+ end
89
+
90
+ def dump_failures(_notification)
91
+ # We output failures immediately as they happen
92
+ end
93
+
94
+ def dump_summary(notification)
95
+ output.puts
96
+ output.puts notification.fully_formatted
97
+ end
98
+
99
+ def seed(notification)
100
+ return unless notification.seed_used?
101
+
102
+ output.puts notification.fully_formatted
103
+ end
104
+
105
+ def close(_notification)
106
+ @progress&.stop
107
+ end
108
+
109
+ private
110
+
111
+ def increment
112
+ return unless @progress
113
+
114
+ with_current_color { @progress.increment }
115
+ end
116
+
117
+ def with_current_color
118
+ return yield unless color_enabled?
119
+
120
+ output.print "\e[#{color_code_for(current_color)}m"
121
+ yield
122
+ output.print "\e[0m"
123
+ end
124
+
125
+ def color_enabled?
126
+ RSpec.configuration.color_enabled? && output.tty? && !continuous_integration?
127
+ end
128
+
129
+ def current_color
130
+ if @failed_count.positive?
131
+ :failure
132
+ elsif @pending_count.positive?
133
+ :pending
134
+ else
135
+ :success
136
+ end
137
+ end
138
+
139
+ def color_code_for(symbol)
140
+ Core::Formatters::ConsoleCodes.console_code_for(symbol)
141
+ end
142
+
143
+ def continuous_integration?
144
+ ENV["CI"] == "true" || ENV["CONTINUOUS_INTEGRATION"] == "true"
145
+ end
146
+ end
147
+ end
metadata ADDED
@@ -0,0 +1,112 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rspec-fuubar
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Mikael Henriksson
8
+ - mhenrixon
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2025-07-12 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: ostruct
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rspec-core
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '3.0'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '3.0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: ruby-progressbar
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '1.4'
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '1.4'
56
+ - !ruby/object:Gem::Dependency
57
+ name: stringio
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ description: the instafailing RSpec progress bar formatter
71
+ email:
72
+ - mikael@mhenrixon.com
73
+ - mikael@zoolutions.llc
74
+ executables: []
75
+ extensions: []
76
+ extra_rdoc_files: []
77
+ files:
78
+ - LICENSE.txt
79
+ - README.md
80
+ - lib/fuubar.rb
81
+ - lib/rspec/fuubar.rb
82
+ homepage: https://github.com/mhenrixon/rspec-fuubar
83
+ licenses:
84
+ - MIT
85
+ metadata:
86
+ bug_tracker_uri: https://github.com/mhenrixon/rspec-fuubar/issues
87
+ changelog_uri: https://github.com/mhenrixon/rspec-fuubar/blob/master/CHANGELOG.md
88
+ documentation_uri: https://github.com/mhenrixon/rspec-fuubar/tree/releases/v1.0.0
89
+ homepage_uri: https://github.com/mhenrixon/rspec-fuubar
90
+ source_code_uri: https://github.com/mhenrixon/rspec-fuubar
91
+ wiki_uri: https://github.com/mhenrixon/rspec-fuubar/wiki
92
+ rubygems_mfa_required: 'true'
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: 3.2.0
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ requirements: []
108
+ rubygems_version: 3.4.19
109
+ signing_key:
110
+ specification_version: 4
111
+ summary: the instafailing RSpec progress bar formatter
112
+ test_files: []