Sha256: 12ad7020591284fe08ab0b008ab9cc39bad7b2a536545d9b17cf6f7654bbb72a

Contents?: true

Size: 1.48 KB

Versions: 6

Compression:

Stored size: 1.48 KB

Contents

require 'spec/runner/formatter/base_text_formatter'

# Code is based on standard SpecdocFormatter, but will print full error details as soon as they are found.
# Successful or pending examples are written only as a dot in the output. Header is only printed if errors occur.
#
# To use it, add the following to your spec/spec.opts:
#  --require
#  lib/rspec_immediate_feedback_formatter.rb
#  --format
#  Spec::Runner::Formatter::ImmediateFeedbackFormatter

module Spec
  module Runner
    module Formatter
      class ImmediateFeedbackFormatter < BaseTextFormatter

        def add_example_group(example_group)
          super
          @current_group = example_group.description
        end

        def example_failed(example, counter, failure)
          if @current_group
            output.puts
            output.puts @current_group
            @current_group = nil  # only print the group name once
          end

          message = if failure.expectation_not_met?
            "- #{example.description} (FAILED - #{counter})"
          else
            "- #{example.description} (ERROR - #{counter})"
          end

          output.puts(red(message))
          dump_failure(counter, failure)  # dump stacktrace immediately
          output.flush
        end

        def example_passed(*)
          output.print green('.')
          output.flush
        end

        def example_pending(*)
          super
          output.print yellow('*')
          output.flush
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 3 rubygems

Version Path
datamapper-dm-core-0.10.0 spec/lib/rspec_immediate_feedback_formatter.rb
datamapper-dm-core-0.10.1 spec/lib/rspec_immediate_feedback_formatter.rb
dm-core-0.10.1 spec/lib/rspec_immediate_feedback_formatter.rb
dm-core-0.10.0 spec/lib/rspec_immediate_feedback_formatter.rb
data_objects-0.10.0 spec/lib/rspec_immediate_feedback_formatter.rb
data_objects-0.9.12 spec/lib/rspec_immediate_feedback_formatter.rb