Class: AppMap::Minitest::Recording

Inherits:
Struct
  • Object
show all
Defined in:
lib/appmap/minitest.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(test, test_name) ⇒ Recording

Returns a new instance of Recording.



17
18
19
20
21
22
# File 'lib/appmap/minitest.rb', line 17

def initialize(test, test_name)
  super

  warn "Starting recording of test #{test.class}.#{test.name}@#{source_location}" if AppMap::Minitest::LOG
  @trace = AppMap.tracing.trace
end

Instance Attribute Details

#testObject

Returns the value of attribute test

Returns:

  • (Object)

    the current value of test



16
17
18
# File 'lib/appmap/minitest.rb', line 16

def test
  @test
end

#test_nameObject

Returns the value of attribute test_name

Returns:

  • (Object)

    the current value of test_name



16
17
18
# File 'lib/appmap/minitest.rb', line 16

def test_name
  @test_name
end

Instance Method Details

#finishObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/appmap/minitest.rb', line 29

def finish
  warn "Finishing recording of test #{test.class}.#{test.name}" if AppMap::Minitest::LOG

  events = []
  AppMap.tracing.delete @trace

  events << @trace.next_event.to_h while @trace.event?

  AppMap::Minitest.add_event_methods @trace.event_methods

  class_map = AppMap.class_map(@trace.event_methods, include_source: AppMap.include_source?)

  feature_group = test.class.name.underscore.split('_')[0...-1].join('_').capitalize
  feature_name = test.name.split('_')[1..-1].join(' ')
  scenario_name = [ feature_group, feature_name ].join(' ')

  AppMap::Minitest.save scenario_name,
                        class_map,
                        source_location,
                        events: events
end

#source_locationObject



24
25
26
# File 'lib/appmap/minitest.rb', line 24

def source_location
  test.method(test_name).source_location.join(':')
end