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::BacktraceCleaner
- RSpec::Core::BacktraceFormatter
- RSpec::Core::CommandLine
- RSpec::Core::Configuration
- RSpec::Core::Configuration::MustBeConfiguredBeforeExampleGroupsError
- RSpec::Core::ConfigurationOptions
- RSpec::Core::ConstMissing
- RSpec::Core::DRbCommandLine
- RSpec::Core::DSL
- RSpec::Core::Deprecation
- RSpec::Core::DrbOptions
- RSpec::Core::Example
- RSpec::Core::Example::NotPendingExampleFixed
- RSpec::Core::Example::Procsy
- RSpec::Core::ExampleGroup
- RSpec::Core::Extensions
- RSpec::Core::Extensions::InstanceEvalWithArgs
- RSpec::Core::Extensions::ModuleEvalWithArgs
- RSpec::Core::Extensions::Ordered
- RSpec::Core::Extensions::Ordered::ExampleGroups
- RSpec::Core::Extensions::Ordered::Examples
- RSpec::Core::FilterManager
- RSpec::Core::FilterManager::BackwardCompatibility
- RSpec::Core::FilterManager::Describable
- RSpec::Core::Formatters
- RSpec::Core::Formatters::BaseFormatter
- RSpec::Core::Formatters::BaseTextFormatter
- RSpec::Core::Formatters::DeprecationFormatter
- RSpec::Core::Formatters::DocumentationFormatter
- RSpec::Core::Formatters::Helpers
- RSpec::Core::Formatters::HtmlFormatter
- RSpec::Core::Formatters::HtmlPrinter
- RSpec::Core::Formatters::JsonFormatter
- RSpec::Core::Formatters::ProgressFormatter
- RSpec::Core::Formatters::SnippetExtractor
- RSpec::Core::Formatters::SnippetExtractor::NullConverter
- RSpec::Core::Formatters::TextMateFormatter
- RSpec::Core::Hooks
- RSpec::Core::Hooks::AfterAllHook
- RSpec::Core::Hooks::AfterHook
- RSpec::Core::Hooks::AroundHook
- RSpec::Core::Hooks::AroundHookCollection
- RSpec::Core::Hooks::BeforeHook
- RSpec::Core::Hooks::GroupHookCollection
- RSpec::Core::Hooks::Hook
- RSpec::Core::Hooks::HookCollection
- RSpec::Core::Hooks::HookCollectionAliases
- RSpec::Core::Hooks::RegistersGlobals
- RSpec::Core::MemoizedHelpers
- RSpec::Core::MemoizedHelpers::BeforeAllMemoizedHash
- RSpec::Core::MemoizedHelpers::ClassMethods
- RSpec::Core::Metadata
- RSpec::Core::Metadata::ExampleMetadataHash
- RSpec::Core::Metadata::GroupMetadataHash
- RSpec::Core::Metadata::MetadataHash
- RSpec::Core::MetadataHashBuilder
- RSpec::Core::MetadataHashBuilder::Common
- RSpec::Core::MetadataHashBuilder::WithConfigWarning
- RSpec::Core::MetadataHashBuilder::WithDeprecationWarning
- RSpec::Core::MockFrameworkAdapter
- RSpec::Core::Parser
- RSpec::Core::Pending
- RSpec::Core::Pending::PendingDeclaredInExample
- RSpec::Core::Pending::PendingExampleFixedError
- RSpec::Core::ProjectInitializer
- RSpec::Core::RakeTask
- RSpec::Core::Reporter
- RSpec::Core::RubyProject
- RSpec::Core::Runner
- RSpec::Core::SharedContext
- RSpec::Core::SharedExampleGroup
- RSpec::Core::SharedExampleGroup::Collection
- RSpec::Core::SharedExampleGroup::Registry
- RSpec::Core::SharedExampleGroup::TopLevelDSL
- RSpec::Core::Time
- RSpec::Core::Version
- RSpec::Core::World
- RSpec::Rake
- RSpec::Runner
- Autotest
- Autotest::Rspec2
- Kernel

No matching classes.

# RSpec::Core::Formatters::HtmlPrinter

### Constants

GLOBAL_SCRIPTS
GLOBAL_STYLES
HTML_HEADER
REPORT_HEADER

### Public Class Methods

new(output) click to toggle source

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

### Public Instance Methods

flush() click to toggle source

    # File lib/rspec/core/formatters/html_printer.rb, line 77
    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 94
    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 99
    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 86
    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 90
    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 81
    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, escape_backtrace = false ) click to toggle source

    # File lib/rspec/core/formatters/html_printer.rb, line 33
    def print_example_failed( pending_fixed, description, run_time, failure_id, exception, extra_content, escape_backtrace = false )
      formatted_run_time = sprintf("%.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>"
        if escape_backtrace
          @output.puts "        <div class=\"backtrace\"><pre>#{h exception[:backtrace]}</pre></div>"
        else
          @output.puts "        <div class=\"backtrace\"><pre>#{exception[:backtrace]}</pre></div>"
        end
      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 17
    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 22
    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 28
    def print_example_passed( description, run_time )
      formatted_run_time = sprintf("%.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 53
    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 12
    def print_html_start
      @output.puts HTML_HEADER
      @output.puts REPORT_HEADER
    end

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

    # File lib/rspec/core/formatters/html_printer.rb, line 57
    def print_summary( was_dry_run, duration, example_count, failure_count, pending_count )
      # TODO - kill dry_run?
      if was_dry_run
        totals = "This was a dry-run"
      else
        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
      end

      formatted_duration = sprintf("%.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.