mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Fix saving feature failures to tmp/capybara
This commit is contained in:
parent
5e656e7d9f
commit
dd5796bd34
1 changed files with 12 additions and 10 deletions
|
|
@ -1,18 +1,20 @@
|
|||
# Automatically save and open the page
|
||||
# whenever an expectation is not met in a features spec
|
||||
# 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
|
||||
ename = RSpec.current_example.full_description
|
||||
ename = ename.gsub ' ', '_'
|
||||
ename.downcase!
|
||||
ename = ename + '.html'
|
||||
example_filename = RSpec.current_example.full_description
|
||||
example_filename = example_filename.tr(' ', '_')
|
||||
example_filename = example_filename + '.html'
|
||||
example_filename = File.expand_path(example_filename, Capybara.save_and_open_page_path)
|
||||
if RSpec.current_example.exception.present?
|
||||
save_page(ename)
|
||||
save_page(example_filename)
|
||||
else
|
||||
capfile = File.expand_path(ename, Capybara.save_and_open_page_path)
|
||||
if File.exist?(capfile)
|
||||
File.unlink(capfile)
|
||||
# remove the file if the test starts working again
|
||||
if File.exist?(example_filename)
|
||||
File.unlink(example_filename)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue