Sha256: 5cda232846c7ec164fbdef5abff2cc73c36e464327ca44813414950360ba7a70

Contents?: true

Size: 1.39 KB

Versions: 62

Compression:

Stored size: 1.39 KB

Contents

require 'parallelized_specs/spec_logger_base'

class ParallelizedSpecs::SharedExampleRerunFailuresLogger < ParallelizedSpecs::SpecLoggerBase

  def example_failed(example, *args)
    if RSPEC_1
      if example.location != nil && example.location.match(/spec.*\d/).to_s != nil
        @failed_shared_examples ||= {}
        if !!self.example_group.nested_descriptions.to_s.match(/shared/) || !!self.instance_variable_get(:@example_group).examples.last.location.match(/helper/)
          spec_caller = example_group.location.match(/spec.*b/).to_s
          failed_shared_spec = example.location.match(/spec.*\d/).to_s
          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
    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

62 entries across 62 versions & 1 rubygems

Version Path
parallelized_specs-0.3.78 lib/parallelized_specs/shared_example_failures_logger.rb
parallelized_specs-0.3.77 lib/parallelized_specs/shared_example_failures_logger.rb
parallelized_specs-0.3.76 lib/parallelized_specs/shared_example_failures_logger.rb
parallelized_specs-0.3.75 lib/parallelized_specs/shared_example_failures_logger.rb
parallelized_specs-0.3.74 lib/parallelized_specs/shared_example_failures_logger.rb
parallelized_specs-0.3.73 lib/parallelized_specs/shared_example_failures_logger.rb
parallelized_specs-0.3.72 lib/parallelized_specs/shared_example_failures_logger.rb
parallelized_specs-0.3.71 lib/parallelized_specs/shared_example_failures_logger.rb
parallelized_specs-0.3.70 lib/parallelized_specs/shared_example_failures_logger.rb
parallelized_specs-0.3.69 lib/parallelized_specs/shared_example_failures_logger.rb
parallelized_specs-0.3.68 lib/parallelized_specs/shared_example_failures_logger.rb
parallelized_specs-0.3.67 lib/parallelized_specs/shared_example_failures_logger.rb
parallelized_specs-0.3.66 lib/parallelized_specs/shared_example_failures_logger.rb
parallelized_specs-0.3.65 lib/parallelized_specs/shared_example_failures_logger.rb
parallelized_specs-0.3.64 lib/parallelized_specs/shared_example_failures_logger.rb
parallelized_specs-0.3.63 lib/parallelized_specs/shared_example_failures_logger.rb
parallelized_specs-0.3.62 lib/parallelized_specs/shared_example_failures_logger.rb
parallelized_specs-0.3.61 lib/parallelized_specs/shared_example_failures_logger.rb
parallelized_specs-0.3.60 lib/parallelized_specs/shared_example_failures_logger.rb
parallelized_specs-0.3.59 lib/parallelized_specs/shared_example_failures_logger.rb