2016-05-02 12:05:58 +02:00
|
|
|
# Automatically save the page a test fails
|
|
|
|
|
Capybara.save_and_open_page_path = Rails.root.join('tmp', 'capybara')
|
|
|
|
|
|
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(' ', '_')
|
2017-06-12 22:37:45 +05:30
|
|
|
example_filename += '.html'
|
2016-05-02 12:05:58 +02:00
|
|
|
example_filename = File.expand_path(example_filename, Capybara.save_and_open_page_path)
|
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)
|
2016-05-02 15:30:22 +02:00
|
|
|
# remove the file if the test starts working again
|
|
|
|
|
elsif File.exist?(example_filename)
|
|
|
|
|
File.unlink(example_filename)
|
2014-07-23 14:55:06 +02:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|