Sha256: a67ac0f1b5551975ad4b29fbd4e1f31a31917d9ca362ab24da6c89d2f0b565d7

Contents?: true

Size: 1.4 KB

Versions: 4

Compression:

Stored size: 1.4 KB

Contents

require 'parallelized_specs/spec_logger_base'

class ParallelizedSpecs::SharedExampleRerunFailuresLogger < ParallelizedSpecs::SpecLoggerBase

  def example_failed(example, *args)
    if RSPEC_1

      if example.location.match(/spec.*\d/).to_s != nil
        @failed_shared_examples ||= {}
        spec_caller = self.example_group.backtrace.match(/spec.*\d/).to_s
        failed_shared_spec = example.location.match(/spec.*\d/).to_s

        if !!self.example_group.nested_descriptions.to_s.match(/shared/) || !!self.instance_variable_get(:@example_group).examples.last.location.match(/helper/)
          if spec_caller == @failed_shared_examples.keys.last || spec_caller == @failed_shared_examples.keys.first
            key = @failed_shared_examples.keys.first
            @failed_shared_examples[key] << "#{failed_shared_spec} "
          else
            @failed_shared_examples["#{spec_caller}"] = ["#{failed_shared_spec} "]
          end

        end
      end #if example.location is nil block ends
    else #if not RSPEC_1
      super
    end
  end

# RSpec 1: dumps 1 failed spec
  def dump_failure(*args)
  end

# RSpec 2: dumps all failed specs
  def dump_failures(*args)
  end

  def dump_summary(*args)
    lock_output do
      if RSPEC_1
        (@failed_shared_examples||{}).each_pair do |caller, example|
          @output.puts "#{caller}:\n\n #{example}\n\n "
        end
      end
      @output.flush
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
parallelized_specs-0.3.12 lib/parallelized_specs/shared_example_failures_logger.rb
parallelized_specs-0.3.11 lib/parallelized_specs/shared_example_failures_logger.rb
parallelized_specs-0.3.10 lib/parallelized_specs/shared_example_failures_logger.rb
parallelized_specs-0.2.92 lib/parallelized_specs/shared_example_failures_logger.rb