Module: TestRecorder::Rails::SetupAndTeardown

Defined in:
lib/test_recorder/rails/setup_and_teardown.rb

Instance Method Summary collapse

Instance Method Details

#before_setupObject



4
5
6
7
8
9
10
# File 'lib/test_recorder/rails/setup_and_teardown.rb', line 4

def before_setup
  @cdp_recorder = TestRecorder::CdpRecorder.new(enabled: TestRecorder.enabled?)
  enabled = respond_to?(:metadata) ? [:test_recorder] : nil
  @cdp_recorder.start(page: page, enabled: enabled)

  super
end

#before_teardownObject



12
13
14
15
16
17
18
19
20
21
# File 'lib/test_recorder/rails/setup_and_teardown.rb', line 12

def before_teardown
  if failures.empty?
    @cdp_recorder.stop_and_discard
  else
    video_path = @cdp_recorder.stop_and_save("failures_#{self.name}.webm")
    puts "[Video]: #{video_path}" if File.exist?(video_path)
  end
ensure
  super
end