class Fuubar
def close(_notification)
def close(_notification) example_tick_thread.kill end
def color_code_for(*args)
def color_code_for(*args) ::RSpec::Core::Formatters::ConsoleCodes.console_code_for(*args) end
def color_enabled?
def color_enabled? configuration.color_enabled? && !continuous_integration? end
def configuration
def configuration ::RSpec.configuration end
def continuous_integration?
def continuous_integration? @continuous_integration ||= \ ![nil, '', 'false'].include?(ENV['CONTINUOUS_INTEGRATION']) end
def current_color
def current_color if failed_count > 0 configuration.failure_color elsif pending_count > 0 configuration.pending_color else configuration.success_color end end
def dump_failures(_notification)
def dump_failures(_notification) # # We output each failure as it happens so we don't need to output them en # masse at the end of the run. # end
def dump_pending(notification)
def dump_pending(notification) return unless configuration.fuubar_output_pending_results super end
def example_failed(notification)
def example_failed(notification) self.failed_count += 1 progress.clear output.puts notification.fully_formatted(failed_count) output.puts increment end
def example_passed(_notification)
def example_passed(_notification) self.passed_count += 1 increment end
def example_pending(_notification)
def example_pending(_notification) self.pending_count += 1 increment end
def example_tick(_notification)
def example_tick(_notification) example_tick_lock.synchronize do refresh end end
def example_tick_thread
def example_tick_thread ::Thread.new do loop do sleep(1) if configuration.fuubar_auto_refresh example_tick(notification) end end end end
def increment
def increment with_current_color { progress.increment } end
def initialize(*args)
def initialize(*args) super self.example_tick_lock = ::Mutex.new self.progress = ::ProgressBar.create( DEFAULT_PROGRESS_BAR_OPTIONS. merge(:throttle_rate => continuous_integration? ? 1.0 : nil). merge(:total => 0, :output => output, :autostart => false) ) end
def message(notification)
def message(notification) if progress.respond_to? :log progress.log(notification.message) else super end end
def output
def output @fuubar_output ||= ::Fuubar::Output.new(super, configuration.tty?) # rubocop:disable Naming/MemoizedInstanceVariableName end
def refresh
def refresh with_current_color { progress.refresh } end
def start(notification)
def start(notification) progress_bar_options = DEFAULT_PROGRESS_BAR_OPTIONS. merge(:throttle_rate => continuous_integration? ? 1.0 : nil). merge(configuration.fuubar_progress_bar_options). merge(:total => notification.count, :output => output, :autostart => false) self.progress = ::ProgressBar.create(progress_bar_options) self.passed_count = 0 self.pending_count = 0 self.failed_count = 0 super with_current_color { progress.start } end
def with_current_color
def with_current_color output.print "\e[#{color_code_for(current_color)}m" if color_enabled? yield output.print "\e[0m" if color_enabled? end