Module: Videotest::Recorder::Rspec

Defined in:
lib/videotest/recorder/rspec.rb

Constant Summary collapse

CHARS_TO_TRANSLATE =
['/', '.', ':', ',', "'", '"', " "].freeze

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.headlessObject

Returns the value of attribute headless.



10
11
12
# File 'lib/videotest/recorder/rspec.rb', line 10

def headless
  @headless
end

.video_dirObject

Returns the value of attribute video_dir.



10
11
12
# File 'lib/videotest/recorder/rspec.rb', line 10

def video_dir
  @video_dir
end

Class Method Details

.after_failed_example(example) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/videotest/recorder/rspec.rb', line 12

def after_failed_example(example)
  if example.exception
    video = video_dir.join("failures_#{method_name(example)}.mp4")
    headless.video.stop_and_save(video)
    example.[:extra_failure_lines] = [example.[:extra_failure_lines], "[Video]: #{video}"]
  else
    headless.video.stop_and_discard
  end
end

.method_name(example) ⇒ Object



22
23
24
# File 'lib/videotest/recorder/rspec.rb', line 22

def method_name(example)
  example.description.underscore.tr(CHARS_TO_TRANSLATE.join, "_")[0...200] + "_#{rand(1000)}"
end