Sha256: 5f84be589f81647280614b721a3f06e1ba49087a02e9d6b081dba41b2e73e1ce

Contents?: true

Size: 1.43 KB

Versions: 19

Compression:

Stored size: 1.43 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 ||= {}
        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

19 entries across 19 versions & 1 rubygems

Version Path
parallelized_specs-0.3.15 lib/parallelized_specs/shared_example_failures_logger.rb
parallelized_specs-0.3.14 lib/parallelized_specs/shared_example_failures_logger.rb
parallelized_specs-0.3.13 lib/parallelized_specs/shared_example_failures_logger.rb
parallelized_specs-0.3.09 lib/parallelized_specs/shared_example_failures_logger.rb
parallelized_specs-0.3.08 lib/parallelized_specs/shared_example_failures_logger.rb
parallelized_specs-0.3.07 lib/parallelized_specs/shared_example_failures_logger.rb
parallelized_specs-0.3.06 lib/parallelized_specs/shared_example_failures_logger.rb
parallelized_specs-0.3.05 lib/parallelized_specs/shared_example_failures_logger.rb
parallelized_specs-0.3.04 lib/parallelized_specs/shared_example_failures_logger.rb
parallelized_specs-0.3.03 lib/parallelized_specs/shared_example_failures_logger.rb
parallelized_specs-0.3.02 lib/parallelized_specs/shared_example_failures_logger.rb
parallelized_specs-0.3.01 lib/parallelized_specs/shared_example_failures_logger.rb
parallelized_specs-0.2.99.01 lib/parallelized_specs/shared_example_failures_logger.rb
parallelized_specs-0.2.99 lib/parallelized_specs/shared_example_failures_logger.rb
parallelized_specs-0.2.98 lib/parallelized_specs/shared_example_failures_logger.rb
parallelized_specs-0.2.97 lib/parallelized_specs/shared_example_failures_logger.rb
parallelized_specs-0.2.96 lib/parallelized_specs/shared_example_failures_logger.rb
parallelized_specs-0.2.95 lib/parallelized_specs/shared_example_failures_logger.rb
parallelized_specs-0.2.94 lib/parallelized_specs/shared_example_failures_logger.rb