Method: RSpec::Core::Configuration#add_formatter

Defined in:
lib/rspec/core/configuration.rb

#add_formatter(formatter) ⇒ Object Also known as: formatter=

Adds a formatter to the formatters collection. formatter can be a string representing any of the built-in formatters (see built_in_formatter), or a custom formatter class.

### Note

For internal purposes, add_formatter also accepts the name of a class and path to a file that contains that class definition, but you should consider that a private api that may change at any time without notice.



446
447
448
449
450
451
452
453
# File 'lib/rspec/core/configuration.rb', line 446

def add_formatter(formatter_to_use, path=nil)
  formatter_class =
    built_in_formatter(formatter_to_use) ||
    custom_formatter(formatter_to_use) ||
    (raise ArgumentError, "Formatter '#{formatter_to_use}' unknown - maybe you meant 'documentation' or 'progress'?.")

  formatters << formatter_class.new(path ? file_at(path) : output)
end