mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Always return an absolute path from save_page, closes #1144
This commit is contained in:
parent
4f678b2bbd
commit
fa798ae3d5
2 changed files with 11 additions and 5 deletions
|
@ -320,7 +320,7 @@ module Capybara
|
|||
#
|
||||
def save_page(path=nil)
|
||||
path ||= "capybara-#{Time.new.strftime("%Y%m%d%H%M%S")}#{rand(10**10)}.html"
|
||||
path = File.expand_path(path, Capybara.save_and_open_page_path) if Capybara.save_and_open_page_path
|
||||
path = File.expand_path(path, Capybara.save_and_open_page_path)
|
||||
|
||||
FileUtils.mkdir_p(File.dirname(path))
|
||||
|
||||
|
|
|
@ -37,11 +37,17 @@ Capybara::SpecHelper.spec '#save_page' do
|
|||
File.read("capybara-001122.html").should include("Another World")
|
||||
end
|
||||
|
||||
it "returns the filename" do
|
||||
it "returns an absolute path in pwd" do
|
||||
result = @session.save_page
|
||||
path = Dir.glob("capybara-*.html").first
|
||||
filename = path.split("/").last
|
||||
result.should == filename
|
||||
path = File.expand_path(Dir.glob("capybara-*.html").first, Dir.pwd)
|
||||
result.should == path
|
||||
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)
|
||||
result.should == path
|
||||
end
|
||||
|
||||
context "asset_host contains a string" do
|
||||
|
|
Loading…
Reference in a new issue