From 1ba99e411a703ca42e8032b3fe0c74df2f15a7e1 Mon Sep 17 00:00:00 2001 From: Thomas Walpole Date: Wed, 17 Aug 2016 13:03:28 -0700 Subject: [PATCH] Remove deprecated Capybara.save_and_open_page_path --- lib/capybara/session.rb | 22 +++++-------------- lib/capybara/spec/session/save_page_spec.rb | 17 -------------- .../spec/session/save_screenshot_spec.rb | 1 - 3 files changed, 5 insertions(+), 35 deletions(-) diff --git a/lib/capybara/session.rb b/lib/capybara/session.rb index 999b91ef..b71d1052 100644 --- a/lib/capybara/session.rb +++ b/lib/capybara/session.rb @@ -731,9 +731,7 @@ module Capybara # # If invoked without arguments it will save file to `Capybara.save_path` # and file will be given randomly generated filename. If invoked with a relative path - # the path will be relative to `Capybara.save_path`, which is different from - # the previous behavior with `Capybara.save_and_open_page_path` where the relative path was - # relative to Dir.pwd + # the path will be relative to `Capybara.save_path` # # @param [String] path the path to where it should be saved # @return [String] the path to which the file was saved @@ -750,9 +748,7 @@ module Capybara # # If invoked without arguments it will save file to `Capybara.save_path` # and file will be given randomly generated filename. If invoked with a relative path - # the path will be relative to `Capybara.save_path`, which is different from - # the previous behavior with `Capybara.save_and_open_page_path` where the relative path was - # relative to Dir.pwd + # the path will be relative to `Capybara.save_path` # # @param [String] path the path to where it should be saved # @@ -767,9 +763,7 @@ module Capybara # # If invoked without arguments it will save file to `Capybara.save_path` # and file will be given randomly generated filename. If invoked with a relative path - # the path will be relative to `Capybara.save_path`, which is different from - # the previous behavior with `Capybara.save_and_open_page_path` where the relative path was - # relative to Dir.pwd + # the path will be relative to `Capybara.save_path` # # @param [String] path the path to where it should be saved # @param [Hash] options a customizable set of options @@ -786,9 +780,7 @@ module Capybara # # If invoked without arguments it will save file to `Capybara.save_path` # and file will be given randomly generated filename. If invoked with a relative path - # the path will be relative to `Capybara.save_path`, which is different from - # the previous behavior with `Capybara.save_and_open_page_path` where the relative path was - # relative to Dir.pwd + # the path will be relative to `Capybara.save_path` # # @param [String] path the path to where it should be saved # @param [Hash] options a customizable set of options @@ -895,11 +887,7 @@ module Capybara end def prepare_path(path, extension) - if config.save_path || config.save_and_open_page_path.nil? - path = File.expand_path(path || default_fn(extension), config.save_path) - else - path = File.expand_path(default_fn(extension), config.save_and_open_page_path) if path.nil? - end + path = File.expand_path(path || default_fn(extension), config.save_path) FileUtils.mkdir_p(File.dirname(path)) path end diff --git a/lib/capybara/spec/session/save_page_spec.rb b/lib/capybara/spec/session/save_page_spec.rb index 09820a69..5fb1c2b5 100644 --- a/lib/capybara/spec/session/save_page_spec.rb +++ b/lib/capybara/spec/session/save_page_spec.rb @@ -6,7 +6,6 @@ Capybara::SpecHelper.spec '#save_page' do end after do - Capybara.save_and_open_page_path = nil Capybara.save_path = nil Dir.glob("capybara-*.html").each do |file| FileUtils.rm(file) @@ -104,20 +103,4 @@ Capybara::SpecHelper.spec '#save_page' do expect(result).to include("Bar") end end - - context "with deprecated save_and_open_page_path" do - it "can store files in a specified directory" do - Capybara.save_and_open_page_path = alternative_path - @session.save_page - path = Dir.glob(alternative_path + "/capybara-*.html").first - expect(File.read(path)).to include("Another World") - end - - it "returns an absolute path in given directory" do - Capybara.save_and_open_page_path = alternative_path - result = @session.save_page - path = File.expand_path(Dir.glob(alternative_path + "/capybara-*.html").first, alternative_path) - expect(result).to eq(path) - end - end end diff --git a/lib/capybara/spec/session/save_screenshot_spec.rb b/lib/capybara/spec/session/save_screenshot_spec.rb index fb1f1a65..de455341 100644 --- a/lib/capybara/spec/session/save_screenshot_spec.rb +++ b/lib/capybara/spec/session/save_screenshot_spec.rb @@ -6,7 +6,6 @@ Capybara::SpecHelper.spec '#save_screenshot', requires: [:screenshot] do end after do - Capybara.save_and_open_page_path = nil Capybara.save_path = nil FileUtils.rm_rf alternative_path end