Class: Profiler::Collectors::TestCollector

Inherits:
BaseCollector show all
Defined in:
lib/profiler/collectors/test_collector.rb

Instance Attribute Summary

Attributes inherited from BaseCollector

#profile

Instance Method Summary collapse

Methods inherited from BaseCollector

descendants, inherited, #name, #panel_content, #render_html, #render_mode, #subscribe

Constructor Details

#initialize(profile, test_name:, test_file:, test_line:, framework:) ⇒ TestCollector

Returns a new instance of TestCollector.



8
9
10
11
12
13
14
15
16
# File 'lib/profiler/collectors/test_collector.rb', line 8

def initialize(profile, test_name:, test_file:, test_line:, framework:)
  super(profile)
  @test_name = test_name
  @test_file = test_file
  @test_line = test_line
  @framework = framework
  @status = "running"
  @exception_message = nil
end

Instance Method Details

#collectObject



47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/profiler/collectors/test_collector.rb', line 47

def collect
  store_data({
    test_name: @test_name,
    test_file: @test_file,
    test_line: @test_line,
    framework: @framework.to_s,
    status: @status,
    exception_message: @exception_message,
    assertions: @assertions,
    skip_reason: @skip_reason
  })
end

#has_data?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/profiler/collectors/test_collector.rb', line 60

def has_data?
  true
end

#iconObject



18
19
20
# File 'lib/profiler/collectors/test_collector.rb', line 18

def icon
  "🧪"
end

#priorityObject



22
23
24
# File 'lib/profiler/collectors/test_collector.rb', line 22

def priority
  5
end

#tab_configObject



26
27
28
29
30
31
32
33
34
35
# File 'lib/profiler/collectors/test_collector.rb', line 26

def tab_config
  {
    key: "test",
    label: "Test",
    icon: icon,
    priority: priority,
    enabled: true,
    default_active: true
  }
end

#toolbar_summaryObject



64
65
66
67
68
69
70
71
72
# File 'lib/profiler/collectors/test_collector.rb', line 64

def toolbar_summary
  color = case @status
          when "passed"  then "green"
          when "failed"  then "red"
          when "pending" then "orange"
          else "gray"
          end
  { text: @status, color: color }
end

#update_extra(assertions: nil, skip_reason: nil) ⇒ Object



42
43
44
45
# File 'lib/profiler/collectors/test_collector.rb', line 42

def update_extra(assertions: nil, skip_reason: nil)
  @assertions = assertions
  @skip_reason = skip_reason
end

#update_status(status, exception_message = nil) ⇒ Object



37
38
39
40
# File 'lib/profiler/collectors/test_collector.rb', line 37

def update_status(status, exception_message = nil)
  @status = status
  @exception_message = exception_message
end