jonleighton/poltergeist — pull request #462 by ivalkeen (2014-03-03 10:45:20+00:00)
Title: Respect `Capybara.save_and_open_page_path` when saving screenshot

Capybara uses `Capybara.save_and_open_page_path` configuration option
to set default path where pages are saved when `save_page` is called. So
if `save_page` is called with the file name only (without path), capybara
saves page into this path. Default value of this option for Rails
application is `Rails.root.join('tmp/capybara')`.

This commit changes poltergeist `save_screenshot` method to respect this
option and thus behave the same as Capybara's `save_page`.

Behaviour before this commit for Rails application (with default value of
`Capybara.save_and_open_page_path`):

save_page('page1.html') # saved to RAILS_ROOT/tmp/capybara/page1.html
save_screenshot('page1.png') # saved to RAILS_ROOT/page1.png

Behaviour after this commit for Rails application (with default value of
`Capybara.save_and_open_page_path`):

save_page('page1.html') # saved to RAILS_ROOT/tmp/capybara/page1.html
save_screenshot('page1.png') # saved to RAILS_ROOT/tmp/capybara/page1.png