Class: RSpec::Core::Formatters::HtmlPrinter

### Home Classes Methods

### In Files

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

### Parent

Object

### Methods

- ::new
- #flush
- #make_example_group_header_red
- #make_example_group_header_yellow
- #make_header_red
- #make_header_yellow
- #move_progress
- #print_example_failed
- #print_example_group_end
- #print_example_group_start
- #print_example_passed
- #print_example_pending
- #print_html_start
- #print_summary

### Included Modules

- ERB::Util

### 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::HtmlPrinter

@private

### Constants

GLOBAL_SCRIPTS

  rubocop:disable LineLength

GLOBAL_STYLES

  rubocop:enable LineLength

HTML_HEADER
REPORT_HEADER

  rubocop:disable LineLength

### Public Class Methods

new(output) click to toggle source

    # File lib/rspec/core/formatters/html_printer.rb, line 9
    def initialize(output)
      @output = output
    end

### Public Instance Methods

flush() click to toggle source

    # File lib/rspec/core/formatters/html_printer.rb, line 79
    def flush
      @output.flush
    end

make_example_group_header_red(group_id) click to toggle source

    # File lib/rspec/core/formatters/html_printer.rb, line 96
    def make_example_group_header_red(group_id)
      @output.puts "    <script type=\"text/javascript\">"                         "makeRed('div_group_#{group_id}');</script>"
      @output.puts "    <script type=\"text/javascript\">"                         "makeRed('example_group_#{group_id}');</script>"
    end

make_example_group_header_yellow(group_id) click to toggle source

    # File lib/rspec/core/formatters/html_printer.rb, line 103
    def make_example_group_header_yellow(group_id)
      @output.puts "    <script type=\"text/javascript\">"                         "makeYellow('div_group_#{group_id}');</script>"
      @output.puts "    <script type=\"text/javascript\">"                         "makeYellow('example_group_#{group_id}');</script>"
    end

make_header_red() click to toggle source

    # File lib/rspec/core/formatters/html_printer.rb, line 88
    def make_header_red
      @output.puts "    <script type=\"text/javascript\">makeRed('rspec-header');</script>"
    end

make_header_yellow() click to toggle source

    # File lib/rspec/core/formatters/html_printer.rb, line 92
    def make_header_yellow
      @output.puts "    <script type=\"text/javascript\">makeYellow('rspec-header');</script>"
    end

move_progress(percent_done) click to toggle source

    # File lib/rspec/core/formatters/html_printer.rb, line 83
    def move_progress(percent_done)
      @output.puts "    <script type=\"text/javascript\">moveProgressBar('#{percent_done}');</script>"
      @output.flush
    end

print_example_failed(pending_fixed, description, run_time, failure_id, exception, extra_content) click to toggle source

rubocop:disable Style/ParameterLists

    # File lib/rspec/core/formatters/html_printer.rb, line 37
    def print_example_failed(pending_fixed, description, run_time, failure_id,
                             exception, extra_content)
      # rubocop:enable Style/ParameterLists
      formatted_run_time = "%.5f" % run_time

      @output.puts "    <dd class=\"example #{pending_fixed ? 'pending_fixed' : 'failed'}\">"
      @output.puts "      <span class=\"failed_spec_name\">#{h(description)}</span>"
      @output.puts "      <span class=\"duration\">#{formatted_run_time}s</span>"
      @output.puts "      <div class=\"failure\" id=\"failure_#{failure_id}\">"
      if exception
        @output.puts "        <div class=\"message\"><pre>#{h(exception[:message])}</pre></div>"
        @output.puts "        <div class=\"backtrace\"><pre>#{h exception[:backtrace]}</pre></div>"
      end
      @output.puts extra_content if extra_content
      @output.puts "      </div>"
      @output.puts "    </dd>"
    end

print_example_group_end() click to toggle source

    # File lib/rspec/core/formatters/html_printer.rb, line 18
    def print_example_group_end
      @output.puts "  </dl>"
      @output.puts "</div>"
    end

print_example_group_start(group_id, description, number_of_parents) click to toggle source

    # File lib/rspec/core/formatters/html_printer.rb, line 23
    def print_example_group_start(group_id, description, number_of_parents)
      @output.puts "<div id=\"div_group_#{group_id}\" class=\"example_group passed\">"
      @output.puts "  <dl #{indentation_style(number_of_parents)}>"
      @output.puts "  <dt id=\"example_group_#{group_id}\" class=\"passed\">#{h(description)}</dt>"
    end

print_example_passed(description, run_time) click to toggle source

    # File lib/rspec/core/formatters/html_printer.rb, line 29
    def print_example_passed(description, run_time)
      formatted_run_time = "%.5f" % run_time
      @output.puts "    <dd class=\"example passed\">"              "<span class=\"passed_spec_name\">#{h(description)}</span>"              "<span class='duration'>#{formatted_run_time}s</span></dd>"
    end

print_example_pending(description, pending_message) click to toggle source

    # File lib/rspec/core/formatters/html_printer.rb, line 55
    def print_example_pending(description, pending_message)
      @output.puts "    <dd class=\"example not_implemented\">"              "<span class=\"not_implemented_spec_name\">#{h(description)} "              "(PENDING: #{h(pending_message)})</span></dd>"
    end

print_html_start() click to toggle source

    # File lib/rspec/core/formatters/html_printer.rb, line 13
    def print_html_start
      @output.puts HTML_HEADER
      @output.puts REPORT_HEADER
    end

print_summary(duration, example_count, failure_count, pending_count) click to toggle source

    # File lib/rspec/core/formatters/html_printer.rb, line 61
    def print_summary(duration, example_count, failure_count, pending_count)
      totals =  "#{example_count} example#{'s' unless example_count == 1}, "
      totals << "#{failure_count} failure#{'s' unless failure_count == 1}"
      totals << ", #{pending_count} pending" if pending_count > 0

      formatted_duration = "%.5f" % duration

      @output.puts "<script type=\"text/javascript\">"              "document.getElementById('duration').innerHTML = \"Finished in "              "<strong>#{formatted_duration} seconds</strong>\";</script>"
      @output.puts "<script type=\"text/javascript\">"              "document.getElementById('totals').innerHTML = \"#{totals}\";</script>"
      @output.puts "</div>"
      @output.puts "</div>"
      @output.puts "</body>"
      @output.puts "</html>"
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.