Fuubar RSpec Formatter

repository·master·Indexed 21 days ago

https://github.com/thekompanee/fuubar

An instafailing RSpec formatter that replaces standard output with a visual progress bar, providing real-time feedback and ETA during test runs. It supports customization via ruby-progressbar options, auto-refresh settings, and integration with debuggers like Pry and Byebug.

Tokens
1.5K
Snippets
12
Records
12
Agent score
26%

What's inside Fuubar

  1. Verify Fuubar gem security

    master

    Fuubar is cryptographically signed. To ensure you are installing a legitimate version, you can add the maintainer's public key and install using the MediumSecurity profile. Note that MediumSecurity is required because the dependency RSpec is not signed.

    # Add the public key
    gem cert --add <(curl -Ls https://raw.github.com/thekompanee/fuubar/master/certs/thekompanee.pem)
    
    # Install with MediumSecurity
    gem install fuubar -P MediumSecurity
  2. Use Fuubar as an RSpec formatter

    master

    Fuubar is an RSpec formatter that provides real-time progress bar feedback. To use it, you must register it as a formatter in your RSpec configuration. This is typically done by adding it to your .rspec file or your spec_helper.rb.

    Note: Fuubar automatically detects if it is running in a Continuous Integration (CI) environment by checking the CONTINUOUS_INTEGRATION environment variable. In CI, it disables certain color features and adjusts the progress bar throttle rate to 1.0 to prevent excessive output.

    # Example: Adding to .rspec
    --format Fuubar
  3. Manage Fuubar auto-refresh with Pry

    master

    If you use Pry for debugging, you can use its hooks to automatically disable fuubar_auto_refresh when entering a session and re-enable it when exiting, preventing visual interference.

    # spec/spec_helper.rb
    
    Pry.config.hooks.add_hook(:before_session, :disable_fuubar_auto_refresh) do |_output, _binding, _pry|
      RSpec.configuration.fuubar_auto_refresh = false
    end
    
    Pry.config.hooks.add_hook(:after_session, :restore_fuubar_auto_refresh) do |_output, _binding, _pry|
      RSpec.configuration.fuubar_auto_refresh = true
    end
  4. Enable Auto-Refresh for the progress bar

    master

    By default, Fuubar only refreshes the bar between specs. To enable an auto-refresh feature that updates the bar (and the ETA) every second, set fuubar_auto_refresh to true.

    Warning: This can interfere with debuggers like byebug or pry by causing the bar to redraw frequently during a session.

    # spec/spec_helper.rb
    
    RSpec.configure do |config|
      config.fuubar_auto_refresh = true
    end
  5. Customize the Fuubar progress bar

    master

    Fuubar uses ruby-progressbar for its display. You can pass custom options to the progress bar by setting the fuubar_progress_bar_options configuration variable in your RSpec.configure block. This allows you to change the format, ETA display, and other progress bar behaviors.

    # spec/spec_helper.rb
    
    RSpec.configure do |config|
      config.fuubar_progress_bar_options = { :format => 'My Fuubar! <%B> %p%% %a' }
    end
  6. Hide Pending/Skipped Spec Summary

    master

    By default, Fuubar outputs a summary of pending specs at the end of the run. To suppress this summary, set fuubar_output_pending_results to false in your RSpec configuration.

    # spec/spec_helper.rb
    
    RSpec.configure do |config|
      config.fuubar_output_pending_results = false
    end
  7. Configure Fuubar RSpec settings

    master

    Fuubar exposes several RSpec configuration settings to customize the progress bar behavior and output. You can set these in your spec_helper.rb or .rspec file using the RSpec.configure block.

    Available settings:

    • fuubar_progress_bar_options: A Hash of options passed directly to ruby-progressbar. This allows you to customize the :format, :throttle_rate, and other progress bar parameters.
    • fuubar_auto_refresh: A Boolean (default: false). When set to true, Fuubar will periodically refresh the progress bar via a background thread.
    • fuubar_output_pending_results: A Boolean (default: true). Controls whether pending results are outputted during the test run.
    RSpec.configure do |config|
      config.fuubar_progress_bar_options = { format: ' %c/%C |%w>%i| %e ' }
      config.fuubar_auto_refresh = true
      config.fuubar_output_pending_results = false
    end