I'm having trouble with tests that download/export a CSV only when running against the grid. When the tests run locally, they are fine. It's because of the way we download and check the file:
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
When I run tests against the grid, the browser on the node is trying to save the file to itself and not to the machine that is running the test. Has anyone run into this issue...and hopefully solved it?