Class: Spec::Runner::Formatter::HtmlFormatter

Inherits:
BaseTextFormatter
  • Object
show all
Defined in:
lib/rasta/extensions/rspec_extensions.rb

Instance Method Summary collapse

Instance Method Details

#example_failed(example, counter, failure) ⇒ Object



146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# File 'lib/rasta/extensions/rspec_extensions.rb', line 146

def example_failed(example, counter, failure)
  failure.exception.backtrace ? extra = extra_failure_content(failure) : extra = ''
  failure_style = failure.pending_fixed? ? 'pending_fixed' : 'failed'
  @output.puts "    <script type=\"text/javascript\">makeRed('rspec-header');</script>" unless @header_red
  @header_red = true
  @output.puts "    <script type=\"text/javascript\">makeRed(\"example_group_#{example_group_number}\");</script>" unless @example_group_red
  @example_group_red = true
  move_progress
  @output.puts "    <dd class=\"spec #{failure_style}\">"
  @output.puts "      <span class=\"failed_spec_name\">#{h(example.description)}</span>"
  @output.puts "      <div class=\"failure\" id=\"failure_#{counter}\">"
  @output.puts "        <div class=\"message\"><pre>#{h(failure.exception.message)}</pre></div>" unless failure.exception.nil?
  @output.puts "        <div class=\"backtrace\"><pre>#{format_backtrace(failure.exception.backtrace)}</pre></div>" unless failure.exception.nil?
  @output.puts extra unless extra == ""
  @output.puts "      </div>"
  @output.puts "    </dd>"
  @output.flush
end

#extra_failure_content(failure) ⇒ Object



165
166
167
168
169
# File 'lib/rasta/extensions/rspec_extensions.rb', line 165

def extra_failure_content(failure)
  require 'spec/runner/formatter/snippet_extractor'
  @snippet_extractor ||= SnippetExtractor.new
  "    <pre class=\"ruby\"><code>#{@snippet_extractor.snippet(failure.exception)}</code></pre>"
end