Sha256: 28b8ef9ba69096aaa0080891fabd9bde47493ba4e438f263c1e27939444b5f4e

Contents?: true

Size: 1.3 KB

Versions: 1

Compression:

Stored size: 1.3 KB

Contents

# frozen_string_literal: true

require "test_notifier"
require "rspec/core"
require "rspec/core/formatters/base_text_formatter"

module RSpec
  module Core
    module Formatters
      class BaseTextFormatter
        alias dump_summary_original dump_summary

        def dump_summary(options)
          dump_summary_original(options)

          example_count = options.example_count
          pending_count = options.pending_count
          examples = options.examples

          return if example_count.zero?

          failure_filter = proc do |error|
            error
              .instance_variable_get(:@exception)
              .instance_of?(RSpec::Expectations::ExpectationNotMetError)
          end

          error_filter = proc {|e|
            %w[
              RSpec::Expectations::ExpectationNotMetError
              NilClass
            ].include?(e.instance_variable_get(:@exception).class.name)
          }

          stats = TestNotifier::Stats.new(
            :rspec,
            {
              count: example_count,
              failures: examples.count(&failure_filter),
              pending: pending_count,
              errors: examples.count(&error_filter)
            }
          )

          TestNotifier.notify(status: stats.status, message: stats.message)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
test_notifier-2.1.0 lib/test_notifier/runner/rspec3.rb