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
end
def download_content
def download_content(ensure_content = true)
wait_for_download
wait_for_download_content if ensure_content
File.read(download)
end
@ -53,10 +54,20 @@ module DownloadedFile
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?
!downloading? && downloads.any?
end
def has_content?
!File.read(download).empty?
end
def downloading?
downloads.grep(/\.part$/).any?
end

Loading…
Cancel
Save