我在使用针对网格运行时下载/导出CSV的测试时遇到问题。当测试在本地运行时,它们很好。这是因为我们下载和检查文件的方式:
module DownloadHelpers
TIMEOUT = 10
PATH = Rails.root.join('tmp/downloads')
def downloads
Dir[PATH.join('*')]
end
def download
downloads.first
end
def download_content
wait_for_download
File.read(download)
end
def wait_for_download
Timeout.timeout(TIMEOUT) do
sleep 0.1 until downloaded?
end
end
def downloaded?
!downloading? && downloads.any?
end
def downloading?
downloads.grep(/\.part$/).any?
end
def clear_downloads
FileUtils.rm_f(downloads)
end
end
当我对网格运行测试时,节点上的浏览器正在尝试将文件保存到自身而不是运行测试的计算机。有没有人遇到这个问题......希望能解决它?