Class: RspecSprint::Normalizer::Snapshot

Inherits:
Struct
  • Object
show all
Defined in:
lib/rspec_sprint/normalizer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#example_countObject

Returns the value of attribute example_count

Returns:

  • (Object)

    the current value of example_count



23
24
25
# File 'lib/rspec_sprint/normalizer.rb', line 23

def example_count
  @example_count
end

#examplesObject

Returns the value of attribute examples

Returns:

  • (Object)

    the current value of examples



23
24
25
# File 'lib/rspec_sprint/normalizer.rb', line 23

def examples
  @examples
end

#factoriesObject

Returns the value of attribute factories

Returns:

  • (Object)

    the current value of factories



23
24
25
# File 'lib/rspec_sprint/normalizer.rb', line 23

def factories
  @factories
end

#factory_timeObject

Returns the value of attribute factory_time

Returns:

  • (Object)

    the current value of factory_time



23
24
25
# File 'lib/rspec_sprint/normalizer.rb', line 23

def factory_time
  @factory_time
end

#failure_countObject

Returns the value of attribute failure_count

Returns:

  • (Object)

    the current value of failure_count



23
24
25
# File 'lib/rspec_sprint/normalizer.rb', line 23

def failure_count
  @failure_count
end

#suite_durationObject

Returns the value of attribute suite_duration

Returns:

  • (Object)

    the current value of suite_duration



23
24
25
# File 'lib/rspec_sprint/normalizer.rb', line 23

def suite_duration
  @suite_duration
end

Instance Method Details

#factory_time_ratioObject

Share of example-run wall time spent building factories (top-level, so cascade time is not double-counted). Denominator = summary.duration (D7).



30
31
32
33
34
# File 'lib/rspec_sprint/normalizer.rb', line 30

def factory_time_ratio
  return 0.0 if suite_duration.nil? || suite_duration.zero?

  factory_time / suite_duration
end

#path_group_durationsObject

run_time summed by the first path segment under spec/ (Rule② data). Deliberately “path group”, not RSpec metadata ‘type:` — see design D10⑦.



42
43
44
45
46
# File 'lib/rspec_sprint/normalizer.rb', line 42

def path_group_durations
  (examples || []).each_with_object(Hash.new(0.0)) do |ex, acc|
    acc[path_group(ex.file_path)] += ex.run_time
  end
end

#slow_examplesObject



36
37
38
# File 'lib/rspec_sprint/normalizer.rb', line 36

def slow_examples
  (examples || []).sort_by { |e| -e.run_time }
end