Sha256: e8477af34e0254eccca921241ac1f533b2c11ba928dec51b4a10224f5c23b117

Contents?: true

Size: 1.67 KB

Versions: 40

Compression:

Stored size: 1.67 KB

Contents

module Fivemat
  class RSpec3
    include ElapsedTime

    # See fivemat.rb for formatter registration.
    attr_reader :output, :failed_notifications

    def initialize(output)
      @output = output
      @group_level = 0
      @index_offset = 0
      @failed_notifications = []
    end

    def color
      unless defined?(::RSpec::Core::Formatters::ConsoleCodes)
        require 'rspec/core/formatters/console_codes'
      end
      ::RSpec::Core::Formatters::ConsoleCodes
    end

    def example_passed(notification)
      output.print color.wrap('.', :success)
    end

    def example_pending(notification)
      output.print color.wrap('*', :pending)
    end

    def example_failed(notification)
      @failed_notifications << notification
      output.print color.wrap('F', :failure)
    end

    def example_group_started(event)
      if @group_level.zero?
        output.print "#{event.group.description} "
        @start_time = Time.now
      end

      @group_level += 1
    end

    def example_group_finished(event)
      @group_level -= 1

      if @group_level.zero?
        print_elapsed_time output, @start_time
        output.puts

        failed_notifications.each_with_index do |failure, index|
          output.puts failure.fully_formatted(@index_offset + index + 1)
        end

        @index_offset += failed_notifications.size
        failed_notifications.clear
      end
    end

    def dump_summary(summary)
      output.puts summary.fully_formatted
    end

    def seed(notification)
      return unless notification.seed_used?
      output.puts notification.fully_formatted
    end

    def message(notification)
      output.puts notification.message
    end
  end
end

Version data entries

40 entries across 40 versions & 7 rubygems

Version Path
logstash-output-scalyr-0.2.1.beta vendor/bundle/jruby/2.5.0/gems/fivemat-1.3.7/lib/fivemat/rspec3.rb
logstash-output-scalyr-0.2.0 vendor/bundle/jruby/2.5.0/gems/fivemat-1.3.7/lib/fivemat/rspec3.rb
logstash-output-scalyr-0.2.0.beta vendor/bundle/jruby/2.5.0/gems/fivemat-1.3.7/lib/fivemat/rspec3.rb
logstash-output-scalyr-0.1.26.beta vendor/bundle/jruby/2.5.0/gems/fivemat-1.3.7/lib/fivemat/rspec3.rb
logstash-output-scalyr-0.1.25.beta vendor/bundle/jruby/2.5.0/gems/fivemat-1.3.7/lib/fivemat/rspec3.rb
logstash-output-scalyr-0.1.24.beta vendor/bundle/jruby/2.5.0/gems/fivemat-1.3.7/lib/fivemat/rspec3.rb
logstash-output-scalyr-0.1.23.beta vendor/bundle/jruby/2.5.0/gems/fivemat-1.3.7/lib/fivemat/rspec3.rb
logstash-output-scalyr-0.1.22.beta vendor/bundle/jruby/2.5.0/gems/fivemat-1.3.7/lib/fivemat/rspec3.rb
logstash-output-scalyr-0.1.21.beta vendor/bundle/jruby/2.5.0/gems/fivemat-1.3.7/lib/fivemat/rspec3.rb
logstash-output-scalyr-0.1.20.beta vendor/bundle/jruby/2.5.0/gems/fivemat-1.3.7/lib/fivemat/rspec3.rb
logstash-output-scalyr-0.1.19.beta vendor/bundle/jruby/2.5.0/gems/fivemat-1.3.7/lib/fivemat/rspec3.rb
logstash-output-scalyr-0.1.18.beta vendor/bundle/jruby/2.5.0/gems/fivemat-1.3.7/lib/fivemat/rspec3.rb
logstash-output-scalyr-0.1.17.beta vendor/bundle/jruby/2.5.0/gems/fivemat-1.3.7/lib/fivemat/rspec3.rb
logstash-output-scalyr-0.1.16.beta vendor/bundle/jruby/2.5.0/gems/fivemat-1.3.7/lib/fivemat/rspec3.rb
logstash-output-scalyr-0.1.15.beta vendor/bundle/jruby/2.5.0/gems/fivemat-1.3.7/lib/fivemat/rspec3.rb
logstash-output-scalyr-0.1.14.beta vendor/bundle/jruby/2.5.0/gems/fivemat-1.3.7/lib/fivemat/rspec3.rb
logstash-output-scalyr-0.1.13 vendor/bundle/jruby/2.5.0/gems/fivemat-1.3.7/lib/fivemat/rspec3.rb
logstash-output-scalyr-0.1.12 vendor/bundle/jruby/2.5.0/gems/fivemat-1.3.7/lib/fivemat/rspec3.rb
logstash-output-scalyr-0.1.11.beta vendor/bundle/jruby/2.5.0/gems/fivemat-1.3.7/lib/fivemat/rspec3.rb
logstash-output-scalyr-0.1.10.beta vendor/bundle/jruby/2.5.0/gems/fivemat-1.3.7/lib/fivemat/rspec3.rb