Sha256: 123c148e3f603a13192670e5084a8563d922ff8bd118307c9e74c4d28c854d89

Contents?: true

Size: 1.26 KB

Versions: 20

Compression:

Stored size: 1.26 KB

Contents

require_relative 'document_io'
require_relative 'html_printer'

module Opal
  module RSpec
    class BrowserFormatter < ::RSpec::Core::Formatters::HtmlFormatter
      ::RSpec::Core::Formatters.register self, :example_group_finished

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

      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

      def example_group_finished(notification)
        @printer.print_example_group_end
      end

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

      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
    end
  end
end

Version data entries

20 entries across 20 versions & 2 rubygems

Version Path
opal-rspec-1.1.0.alpha3 lib-opal/opal/rspec/formatter/browser_formatter.rb
opal-rspec-1.1.0.alpha2 lib-opal/opal/rspec/formatter/browser_formatter.rb
opal-rspec-1.1.0.alpha1 lib-opal/opal/rspec/formatter/browser_formatter.rb
opal-rspec-1.0.0 lib-opal/opal/rspec/formatter/browser_formatter.rb
opal-rspec-1.0.0.alpha1 lib-opal/opal/rspec/formatter/browser_formatter.rb
opal-rspec-0.8.0 lib-opal/opal/rspec/formatter/browser_formatter.rb
opal-rspec-0.8.0.alpha3 lib-opal/opal/rspec/formatter/browser_formatter.rb
opal-rspec-0.8.0.alpha2 lib-opal/opal/rspec/formatter/browser_formatter.rb
opal-rspec-0.8.0.alpha1 lib-opal/opal/rspec/formatter/browser_formatter.rb
opal-rspec-0.7.1 lib-opal/opal/rspec/formatter/browser_formatter.rb
opal-rspec-0.7.0 lib-opal/opal/rspec/formatter/browser_formatter.rb
opal-rspec-0.6.2 opal/opal/rspec/formatter/browser_formatter.rb
opal-rspec-0.7.0.rc.2 lib-opal/opal/rspec/formatter/browser_formatter.rb
opal-rspec-0.7.0.rc.1 lib-opal/opal/rspec/formatter/browser_formatter.rb
opal-rspec-0.6.1 opal/opal/rspec/formatter/browser_formatter.rb
opal-rspec-0.6.0 opal/opal/rspec/formatter/browser_formatter.rb
opal-rspec-0.6.0.beta1 opal/opal/rspec/formatter/browser_formatter.rb
opal-connect-rspec-0.5.0 opal/opal/rspec/formatter/browser_formatter.rb
opal-rspec-0.5.0 opal/opal/rspec/formatter/browser_formatter.rb
opal-rspec-0.5.0.beta3 opal/opal/rspec/formatter/browser_formatter.rb