Remove deprecated Capybara.save_and_open_page_path

This commit is contained in:
Thomas Walpole 2016-08-17 13:03:28 -07:00
parent 98b9034842
commit 1ba99e411a
3 changed files with 5 additions and 35 deletions

View File

@ -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

View File

@ -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

View File

@ -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