Class: RSpec::Core::Formatters::HtmlFormatter

### Home Classes Methods

### In Files

- lib/rspec/core/formatters/html_formatter.rb

### Parent

RSpec::Core::Formatters::BaseFormatter

### Methods

- ::new
- #dump_summary
- #example_failed
- #example_group_started
- #example_passed
- #example_pending
- #example_started
- #start
- #start_dump

### Class/Module Index

Quicksearch

- RSpec
- RSpec::Core
- RSpec::Core::AnonymousExampleGroup
- RSpec::Core::Backports
- RSpec::Core::Backports::Random
- RSpec::Core::Backports::Random::Implementation
- RSpec::Core::Backports::Random::MT19937
- RSpec::Core::BacktraceFormatter
- 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::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::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::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::ContextHookMemoizedHash
- RSpec::Core::MemoizedHelpers::ContextHookMemoizedHash::After
- RSpec::Core::MemoizedHelpers::ContextHookMemoizedHash::Before
- 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::Notifications
- 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::PendingExampleNotificationMethods
- 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::ProjectInitializer
- RSpec::Core::RakeTask
- RSpec::Core::RandomNumberGenerator
- RSpec::Core::Reporter
- RSpec::Core::RubyProject
- RSpec::Core::Runner
- RSpec::Core::Sandbox
- RSpec::Core::SharedContext
- RSpec::Core::SharedExampleGroup
- RSpec::Core::SharedExampleGroup::Registry
- RSpec::Core::SharedExampleGroup::TopLevelDSL
- RSpec::Core::SharedExampleGroupInclusionStackFrame
- RSpec::Core::SharedExampleGroupModule
- 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::HtmlFormatter

@private

### Public Class Methods

new(output) click to toggle source

    # File lib/rspec/core/formatters/html_formatter.rb, line 13
    def initialize(output)
      super(output)
      @failed_examples = []
      @example_group_number = 0
      @example_number = 0
      @header_red = nil
      @printer = HtmlPrinter.new(output)
    end

### Public Instance Methods

dump_summary(summary) click to toggle source

    # File lib/rspec/core/formatters/html_formatter.rb, line 104
    def dump_summary(summary)
      @printer.print_summary(
        summary.duration,
        summary.example_count,
        summary.failure_count,
        summary.pending_count
      )
      @printer.flush
    end

example_failed(failure) click to toggle source

    # File lib/rspec/core/formatters/html_formatter.rb, line 55
    def example_failed(failure)
      @failed_examples << failure.example
      unless @header_red
        @header_red = true
        @printer.make_header_red
      end

      unless @example_group_red
        @example_group_red = true
        @printer.make_example_group_header_red(example_group_number)
      end

      @printer.move_progress(percent_done)

      example = failure.example

      exception = failure.exception
      exception_details = if exception
                            {
                              :message => exception.message,
                              :backtrace => failure.formatted_backtrace.join("\n")
                            }
                          else
                            false
                          end
      extra = extra_failure_content(failure)

      @printer.print_example_failed(
        example.execution_result.pending_fixed,
        example.description,
        example.execution_result.run_time,
        @failed_examples.size,
        exception_details,
        (extra == "") ? false : extra,
        true
      )
      @printer.flush
    end

example_group_started(notification) click to toggle source

    # File lib/rspec/core/formatters/html_formatter.rb, line 28
    def example_group_started(notification)
      super
      @example_group_red = false
      @example_group_number += 1

      @printer.print_example_group_end unless example_group_number == 1
      @printer.print_example_group_start(example_group_number,
                                         notification.group.description,
                                         notification.group.parent_groups.size)
      @printer.flush
    end

example_passed(passed) click to toggle source

    # File lib/rspec/core/formatters/html_formatter.rb, line 49
    def example_passed(passed)
      @printer.move_progress(percent_done)
      @printer.print_example_passed(passed.example.description, passed.example.execution_result.run_time)
      @printer.flush
    end

example_pending(pending) click to toggle source

    # File lib/rspec/core/formatters/html_formatter.rb, line 94
    def example_pending(pending)
      example = pending.example

      @printer.make_header_yellow unless @header_red
      @printer.make_example_group_header_yellow(example_group_number) unless @example_group_red
      @printer.move_progress(percent_done)
      @printer.print_example_pending(example.description, example.execution_result.pending_message)
      @printer.flush
    end

example_started(_notification) click to toggle source

    # File lib/rspec/core/formatters/html_formatter.rb, line 45
    def example_started(_notification)
      @example_number += 1
    end

start(notification) click to toggle source

    # File lib/rspec/core/formatters/html_formatter.rb, line 22
    def start(notification)
      super
      @printer.print_html_start
      @printer.flush
    end

start_dump(_notification) click to toggle source

    # File lib/rspec/core/formatters/html_formatter.rb, line 40
    def start_dump(_notification)
      @printer.print_example_group_end
      @printer.flush
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.