Module: TestRecorder::RSpec
- Defined in:
- lib/test_recorder/rspec.rb,
lib/test_recorder/rspec/example_wrapper.rb
Defined Under Namespace
Modules: ExampleWrapper
Constant Summary collapse
- CHARS_TO_TRANSLATE =
['/', '.', ':', ',', "'", '"', " "].freeze
Class Attribute Summary collapse
-
.cdp_recorder ⇒ Object
Returns the value of attribute cdp_recorder.
Class Method Summary collapse
Class Attribute Details
.cdp_recorder ⇒ Object
Returns the value of attribute cdp_recorder.
9 10 11 |
# File 'lib/test_recorder/rspec.rb', line 9 def cdp_recorder @cdp_recorder end |
Class Method Details
.after_failed_example(example) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/test_recorder/rspec.rb', line 11 def after_failed_example(example) if passed?(example) cdp_recorder.stop_and_discard else video_path = cdp_recorder.stop_and_save("failures_#{method_name(example)}.webm").to_s if File.exist?(video_path) example.[:extra_failure_lines] = [example.[:extra_failure_lines], "[Video]: #{video_path}"].flatten end end end |
.method_name(example) ⇒ Object
22 23 24 |
# File 'lib/test_recorder/rspec.rb', line 22 def method_name(example) example.description.underscore.tr(CHARS_TO_TRANSLATE.join, "_")[0...200] + "_#{rand(1000)}" end |
.passed?(example) ⇒ Boolean
26 27 28 29 30 31 32 33 34 |
# File 'lib/test_recorder/rspec.rb', line 26 def passed?(example) return false if example.exception return true unless defined?(::RSpec::Expectations::FailureAggregator) failure_notifier = ::RSpec::Support.failure_notifier return true unless failure_notifier.is_a?(::RSpec::Expectations::FailureAggregator) failure_notifier.failures.empty? && failure_notifier.other_errors.empty? end |