2018-05-07 16:47:29 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2014-07-23 14:55:06 +02:00
|
|
|
RSpec.configure do |config|
|
|
|
|
|
config.after(:each, type: :feature) do
|
2016-05-02 12:05:58 +02:00
|
|
|
example_filename = RSpec.current_example.full_description
|
|
|
|
|
example_filename = example_filename.tr(' ', '_')
|
2018-11-19 09:36:39 -08:00
|
|
|
example_filename = File.expand_path(example_filename, Capybara.save_path)
|
2019-03-15 14:56:23 +01:00
|
|
|
example_screenshotname = "#{example_filename}.png"
|
|
|
|
|
example_filename += '.html'
|
2014-07-23 14:55:06 +02:00
|
|
|
if RSpec.current_example.exception.present?
|
2016-05-02 12:05:58 +02:00
|
|
|
save_page(example_filename)
|
2020-04-05 10:20:46 -07:00
|
|
|
save_screenshot(example_screenshotname) # rubocop:disable Lint/Debugger
|
2016-05-02 15:30:22 +02:00
|
|
|
# remove the file if the test starts working again
|
2019-03-15 14:56:23 +01:00
|
|
|
else
|
|
|
|
|
File.unlink(example_filename) if File.exist?(example_filename)
|
|
|
|
|
File.unlink(example_screenshotname) if File.exist?(example_screenshotname)
|
2014-07-23 14:55:06 +02:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|