Closed yanowitz closed 7 years ago
@mattheworiordan was this a terrible idea or are you just terribly busy?
@yanowitz I apologize. I am just terribly busy and neglected this gem.
Thanks for your contribution, however I am confused, how is:
if Capybara.page.current_url != '' && Capybara::Screenshot.autosave_on_failure && example.exception
any different logically to?
if Capybara::Screenshot.autosave_on_failure && example.exception && Capybara.page.current_url != ''
Fair question.
Capybara.page.current_url
has a side-effect: it launches (opens) a browser if one is not already launched. So by putting it after the other two pieces of the conditional, we short circuit if there has been no exception and do not launch the browser.
has a side-effect: it launches (opens) a browser if one is not already launched
Ah, thanks for explaining.
Thanks for the contribution!
The previous logic meant every test (even ones that didn't use Capybara) caused Firefox to open after every test, even when there wasn't a test failure.
There's probably a better way to do this (Capybara::DSL ends up in all our rspec groups) based on whether it was an integration test or made use of Capybara, but this at least solves a chunk of the annoyance.