|
|
@ -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 |
|
|
|