Class: TestProf::RSpecDissect::Collectors::Let

Inherits:
Base
  • Object
show all
Defined in:
lib/test_prof/rspec_dissect/collectors/let.rb

Instance Attribute Summary

Attributes inherited from Base

#name, #results, #top_count

Instance Method Summary collapse

Methods inherited from Base

#<<, #print_name, #print_result_header, #total_time, #total_time_message

Constructor Details

#initialize(params) ⇒ Let

Returns a new instance of Let.



9
10
11
# File 'lib/test_prof/rspec_dissect/collectors/let.rb', line 9

def initialize(params)
  super(name: :let, **params)
end

Instance Method Details

#populate!(data) ⇒ Object



13
14
15
16
# File 'lib/test_prof/rspec_dissect/collectors/let.rb', line 13

def populate!(data)
  super
  data[:let_calls] = RSpecDissect.meta_for(name)
end


23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/test_prof/rspec_dissect/collectors/let.rb', line 23

def print_group_result(group)
  return super unless RSpecDissect.config.let_stats_enabled?
  msgs = [super]
  group[:let_calls]
    .group_by(&:itself)
    .map { |id, calls| [id, -calls.size] }
    .sort_by(&:last)
    .take(RSpecDissect.config.let_top_count)
    .each do |(id, size)|
    msgs << "#{id}#{-size}\n"
  end
  msgs.join
end


18
19
20
21
# File 'lib/test_prof/rspec_dissect/collectors/let.rb', line 18

def print_results
  return unless RSpecDissect.memoization_available?
  super
end