Class: Opal::RSpec::BrowserFormatter

Inherits:
RSpec::Core::Formatters::HtmlFormatter
  • Object
show all
Defined in:
opal/opal/rspec/formatter/browser_formatter.rb

Instance Method Summary collapse

Constructor Details

#initialize(output) ⇒ BrowserFormatter

Returns a new instance of BrowserFormatter.



9
10
11
12
# File 'opal/opal/rspec/formatter/browser_formatter.rb', line 9

def initialize(output)
  super DocumentIO.new
  @printer = Opal::RSpec::HtmlPrinter.new(@output)
end

Instance Method Details

#example_group_finished(notification) ⇒ Object



23
24
25
# File 'opal/opal/rspec/formatter/browser_formatter.rb', line 23

def example_group_finished(notification)
  @printer.print_example_group_end
end

#example_group_started(notification) ⇒ Object



14
15
16
17
18
19
20
21
# File 'opal/opal/rspec/formatter/browser_formatter.rb', line 14

def example_group_started(notification)
  # Since we hook print_example_group_end, we override this method
  @example_group_red = false
  @example_group_number += 1

  @printer.print_example_group_start(example_group_number, notification.group.description, notification.group.parent_groups.size)
  @printer.flush
end

#extra_failure_content(failure) ⇒ Object



31
32
33
34
35
# File 'opal/opal/rspec/formatter/browser_formatter.rb', line 31

def extra_failure_content(failure)
  backtrace = failure.exception.backtrace.map { |line| ::RSpec.configuration.backtrace_formatter.backtrace_line(line) }
  # No snippet extractor due to code ray dependency
  "    <pre class=\"ruby\"><code>#{backtrace.compact}</code></pre>"
end

#start_dump(_notification) ⇒ Object



27
28
29
# File 'opal/opal/rspec/formatter/browser_formatter.rb', line 27

def start_dump(_notification)
  # Don't need to call "print_example_group_end" like base does since we hook that event
end