Merge pull request #2436 from Ana06/screenshot

Store screenshot when feature test fails
This commit is contained in:
Henne Vogelsang 2019-03-18 16:18:16 +01:00 committed by GitHub
commit 0197ed3c46
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4,13 +4,16 @@ RSpec.configure do |config|
config.after(:each, type: :feature) do
example_filename = RSpec.current_example.full_description
example_filename = example_filename.tr(' ', '_')
example_filename += '.html'
example_filename = File.expand_path(example_filename, Capybara.save_path)
example_screenshotname = "#{example_filename}.png"
example_filename += '.html'
if RSpec.current_example.exception.present?
save_page(example_filename)
save_page(example_screenshotname)
# remove the file if the test starts working again
elsif File.exist?(example_filename)
File.unlink(example_filename)
else
File.unlink(example_filename) if File.exist?(example_filename)
File.unlink(example_screenshotname) if File.exist?(example_screenshotname)
end
end
end