Module: RSpec::Core::Formatters

### Home Classes Methods

### In Files

- lib/rspec/core/formatters.rb
- lib/rspec/core/formatters/base_formatter.rb
- lib/rspec/core/formatters/base_text_formatter.rb
- lib/rspec/core/formatters/bisect_formatter.rb
- lib/rspec/core/formatters/bisect_progress_formatter.rb
- lib/rspec/core/formatters/console_codes.rb
- lib/rspec/core/formatters/deprecation_formatter.rb
- lib/rspec/core/formatters/documentation_formatter.rb
- lib/rspec/core/formatters/exception_presenter.rb
- lib/rspec/core/formatters/fallback_message_formatter.rb
- lib/rspec/core/formatters/helpers.rb
- lib/rspec/core/formatters/html_formatter.rb
- lib/rspec/core/formatters/html_printer.rb
- lib/rspec/core/formatters/json_formatter.rb
- lib/rspec/core/formatters/profile_formatter.rb
- lib/rspec/core/formatters/progress_formatter.rb
- lib/rspec/core/formatters/protocol.rb
- lib/rspec/core/formatters/snippet_extractor.rb

### Namespace

- MODULE RSpec::Core::Formatters::ConsoleCodes
- MODULE RSpec::Core::Formatters::Helpers
- CLASS RSpec::Core::Formatters::BaseFormatter
- CLASS RSpec::Core::Formatters::BaseTextFormatter
- CLASS RSpec::Core::Formatters::BisectDebugFormatter
- CLASS RSpec::Core::Formatters::BisectFormatter
- CLASS RSpec::Core::Formatters::BisectProgressFormatter
- CLASS RSpec::Core::Formatters::DeprecationFormatter
- CLASS RSpec::Core::Formatters::DocumentationFormatter
- CLASS RSpec::Core::Formatters::ExceptionPresenter
- CLASS RSpec::Core::Formatters::FallbackMessageFormatter
- CLASS RSpec::Core::Formatters::HtmlFormatter
- CLASS RSpec::Core::Formatters::HtmlPrinter
- CLASS RSpec::Core::Formatters::JsonFormatter
- CLASS RSpec::Core::Formatters::Loader
- CLASS RSpec::Core::Formatters::ProfileFormatter
- CLASS RSpec::Core::Formatters::ProgressFormatter
- CLASS RSpec::Core::Formatters::Protocol
- CLASS RSpec::Core::Formatters::SnippetExtractor

### Methods

- ::register

### Class/Module Index

Quicksearch

- RSpec
- RSpec::Core
- RSpec::Core::AnonymousExampleGroup
- RSpec::Core::BacktraceFormatter
- RSpec::Core::Bisect
- RSpec::Core::Bisect::Coordinator
- RSpec::Core::Bisect::ExampleMinimizer
- RSpec::Core::Bisect::Runner
- RSpec::Core::Bisect::Server
- RSpec::Core::Bisect::SubsetEnumerator
- RSpec::Core::Configuration
- RSpec::Core::Configuration::DeprecationReporterBuffer
- RSpec::Core::Configuration::ExposeCurrentExample
- RSpec::Core::Configuration::MustBeConfiguredBeforeExampleGroupsError
- RSpec::Core::ConfigurationOptions
- RSpec::Core::DRbOptions
- RSpec::Core::DRbRunner
- RSpec::Core::DSL
- RSpec::Core::DSL::RSpec
- RSpec::Core::Example
- RSpec::Core::Example::ExecutionResult
- RSpec::Core::Example::Procsy
- RSpec::Core::ExampleGroup
- RSpec::Core::ExampleStatusDumper
- RSpec::Core::ExampleStatusMerger
- RSpec::Core::ExampleStatusParser
- RSpec::Core::ExampleStatusPersister
- RSpec::Core::ExclusionRules
- RSpec::Core::FilterManager
- RSpec::Core::FilterRules
- RSpec::Core::FilterableItemRepository
- RSpec::Core::FilterableItemRepository::QueryOptimized
- RSpec::Core::FilterableItemRepository::UpdateOptimized
- RSpec::Core::FlatMap
- RSpec::Core::Formatters
- RSpec::Core::Formatters::BaseFormatter
- RSpec::Core::Formatters::BaseTextFormatter
- RSpec::Core::Formatters::BisectDebugFormatter
- RSpec::Core::Formatters::BisectFormatter
- RSpec::Core::Formatters::BisectProgressFormatter
- RSpec::Core::Formatters::ConsoleCodes
- RSpec::Core::Formatters::DeprecationFormatter
- RSpec::Core::Formatters::DeprecationFormatter::DelayedPrinter
- RSpec::Core::Formatters::DeprecationFormatter::FileStream
- RSpec::Core::Formatters::DeprecationFormatter::ImmediatePrinter
- RSpec::Core::Formatters::DeprecationFormatter::RaiseErrorStream
- RSpec::Core::Formatters::DocumentationFormatter
- RSpec::Core::Formatters::ExceptionPresenter
- RSpec::Core::Formatters::ExceptionPresenter::Factory
- RSpec::Core::Formatters::ExceptionPresenter::Factory::CommonBacktraceTruncater
- RSpec::Core::Formatters::ExceptionPresenter::Factory::EmptyBacktraceFormatter
- RSpec::Core::Formatters::FallbackMessageFormatter
- RSpec::Core::Formatters::Helpers
- RSpec::Core::Formatters::HtmlFormatter
- RSpec::Core::Formatters::HtmlPrinter
- RSpec::Core::Formatters::JsonFormatter
- RSpec::Core::Formatters::Loader
- RSpec::Core::Formatters::ProfileFormatter
- RSpec::Core::Formatters::ProgressFormatter
- RSpec::Core::Formatters::Protocol
- RSpec::Core::Formatters::SnippetExtractor
- RSpec::Core::Formatters::SnippetExtractor::CoderayConverter
- RSpec::Core::Formatters::SnippetExtractor::NullConverter
- RSpec::Core::HashImitatable
- RSpec::Core::HashImitatable::ClassMethods
- RSpec::Core::Hooks
- RSpec::Core::Hooks::AfterContextHook
- RSpec::Core::Hooks::AfterHook
- RSpec::Core::Hooks::AroundHook
- RSpec::Core::Hooks::BeforeHook
- RSpec::Core::Hooks::Hook
- RSpec::Core::Hooks::HookCollections
- RSpec::Core::InclusionRules
- RSpec::Core::LegacyExampleGroupHash
- RSpec::Core::MemoizedHelpers
- RSpec::Core::MemoizedHelpers::ClassMethods
- RSpec::Core::MemoizedHelpers::ContextHookMemoized
- RSpec::Core::MemoizedHelpers::ContextHookMemoized::After
- RSpec::Core::MemoizedHelpers::ContextHookMemoized::Before
- RSpec::Core::MemoizedHelpers::NonThreadSafeMemoized
- RSpec::Core::MemoizedHelpers::ThreadsafeMemoized
- RSpec::Core::Metadata
- RSpec::Core::Metadata::ExampleGroupHash
- RSpec::Core::Metadata::ExampleHash
- RSpec::Core::Metadata::HashPopulator
- RSpec::Core::MetadataFilter
- RSpec::Core::MinitestAssertionsAdapter
- RSpec::Core::MockingAdapters
- RSpec::Core::MockingAdapters::Flexmock
- RSpec::Core::MockingAdapters::Mocha
- RSpec::Core::MockingAdapters::Null
- RSpec::Core::MockingAdapters::RR
- RSpec::Core::MockingAdapters::RSpec
- RSpec::Core::MultipleExceptionError
- RSpec::Core::MultipleExceptionError::InterfaceTag
- RSpec::Core::Mutex
- RSpec::Core::Notifications
- RSpec::Core::Notifications::CustomNotification
- RSpec::Core::Notifications::DeprecationNotification
- RSpec::Core::Notifications::ExampleNotification
- RSpec::Core::Notifications::ExamplesNotification
- RSpec::Core::Notifications::FailedExampleNotification
- RSpec::Core::Notifications::NullColorizer
- RSpec::Core::Notifications::NullNotification
- RSpec::Core::Notifications::PendingExampleFailedAsExpectedNotification
- RSpec::Core::Notifications::PendingExampleFixedNotification
- RSpec::Core::Notifications::ProfileNotification
- RSpec::Core::Notifications::SeedNotification
- RSpec::Core::Notifications::SkippedExampleNotification
- RSpec::Core::Notifications::SummaryNotification
- RSpec::Core::NullReporter
- RSpec::Core::Ordering
- RSpec::Core::Ordering::ConfigurationManager
- RSpec::Core::Ordering::Custom
- RSpec::Core::Ordering::Identity
- RSpec::Core::Ordering::Random
- RSpec::Core::Ordering::Registry
- RSpec::Core::Parser
- RSpec::Core::Pending
- RSpec::Core::Pending::PendingExampleFixedError
- RSpec::Core::Pending::SkipDeclaredInExample
- RSpec::Core::Profiler
- RSpec::Core::ProjectInitializer
- RSpec::Core::RakeTask
- RSpec::Core::ReentrantMutex
- RSpec::Core::Reporter
- RSpec::Core::RubyProject
- RSpec::Core::Runner
- RSpec::Core::Sandbox
- RSpec::Core::Set
- RSpec::Core::SharedContext
- RSpec::Core::SharedExampleGroup
- RSpec::Core::SharedExampleGroup::Registry
- RSpec::Core::SharedExampleGroup::TopLevelDSL
- RSpec::Core::SharedExampleGroupInclusionStackFrame
- RSpec::Core::SharedExampleGroupModule
- RSpec::Core::ShellEscape
- RSpec::Core::SuiteHookContext
- RSpec::Core::TestUnitAssertionsAdapter
- RSpec::Core::Time
- RSpec::Core::Version
- RSpec::Core::Warnings
- RSpec::Core::World
- RSpec::ExampleGroups
- Object

No matching classes.

# RSpec::Core::Formatters

## Built-in Formatters

- progress (default) - Prints dots for passing examples, `F` for failures, `*`

      for pending.

- documentation - Prints the docstrings passed to `describe` and `it` methods

      (and their aliases).

- html

- json - Useful for archiving data for subsequent analysis.

The progress formatter is the default, but you can choose any one or more of the other formatters by passing with the `--format` (or `-f` for short) command-line option, e.g.

    rspec --format documentation

You can also send the output of multiple formatters to different streams, e.g.

    rspec --format documentation --format html --out results.html

This example sends the output of the documentation formatter to `$stdout`, and the output of the html formatter to results.html.

## Custom Formatters

You can tell RSpec to use a custom formatter by passing its path and name to the `rspec` commmand. For example, if you define MyCustomFormatter in path/to/my_custom_formatter.rb, you would type this command:

    rspec --require path/to/my_custom_formatter.rb --format MyCustomFormatter

The reporter calls every formatter with this protocol:

- To start

  - `start(StartNotification)`

- Once per example group

  - `example_group_started(GroupNotification)`

- Once per example

  - `example_started(ExampleNotification)`

- One of these per example, depending on outcome

  - `example_passed(ExampleNotification)`

  - `example_failed(FailedExampleNotification)`

  - `example_pending(ExampleNotification)`

- Optionally at any time

  - `message(MessageNotification)`

- At the end of the suite

  - `stop(ExamplesNotification)`

  - `start_dump(NullNotification)`

  - `dump_pending(ExamplesNotification)`

  - `dump_failures(ExamplesNotification)`

  - `dump_summary(SummaryNotification)`

  - `seed(SeedNotification)`

  - `close(NullNotification)`

Only the notifications to which you subscribe your formatter will be called on your formatter. To subscribe your formatter use: `RSpec::Core::Formatters#register` e.g.

`RSpec::Core::Formatters.register FormatterClassName, :example_passed, :example_failed`

We recommend you implement the methods yourself; for simplicity we provide the default formatter output via our notification objects but if you prefer you can subclass `RSpec::Core::Formatters::BaseTextFormatter` and override the methods you wish to enhance.

@see RSpec::Core::Formatters::BaseTextFormatter @see RSpec::Core::Reporter

### Public Class Methods

register(formatter_class, *notifications) click to toggle source

Register the formatter class @param formatter_class [Class] formatter class to register @param notifications [Symbol, ...] one or more notifications to be

    registered to the specified formatter

@see RSpec::Core::Formatters::BaseFormatter

    # File lib/rspec/core/formatters.rb, line 83
    def self.register(formatter_class, *notifications)
      Loader.formatters[formatter_class] = notifications
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.