ensure file has content

pull/5029/head
Jens Ulferts 8 years ago
parent f8cf3fe2c1
commit 632faa762a
No known key found for this signature in database
GPG Key ID: 3CAA4B1182CF5308
  1. 13
      spec/support/downloaded_file.rb

@ -42,8 +42,9 @@ module DownloadedFile
downloads.first downloads.first
end end
def download_content def download_content(ensure_content = true)
wait_for_download wait_for_download
wait_for_download_content if ensure_content
File.read(download) File.read(download)
end end
@ -53,10 +54,20 @@ module DownloadedFile
end end
end end
def wait_for_download_content
Timeout.timeout(Capybara.default_max_wait_time) do
sleep 0.1 until has_content?
end
end
def downloaded? def downloaded?
!downloading? && downloads.any? !downloading? && downloads.any?
end end
def has_content?
!File.read(download).empty?
end
def downloading? def downloading?
downloads.grep(/\.part$/).any? downloads.grep(/\.part$/).any?
end end

Loading…
Cancel
Save