Files
osem/spec/support/save_feature_failures.rb
divyanshumehta cdf794ecbf Add Style/SelfAssignment Rubocop cop
The cop enforces use of self assignment operator E.g. a=a+2 gets
written as a+=2. Also the offenses listed in rubocop.todo.yml
have been corrected automatically with the --auto-correct option.
Fixes issue #1531
2017-06-14 09:22:19 +05:30

18 lines
653 B
Ruby

# Automatically save the page a test fails
Capybara.save_and_open_page_path = Rails.root.join('tmp', 'capybara')
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_and_open_page_path)
if RSpec.current_example.exception.present?
save_page(example_filename)
# remove the file if the test starts working again
elsif File.exist?(example_filename)
File.unlink(example_filename)
end
end
end