Sha256: b5b7a563e4462cc085569009e95e61506ff306395a44d23a6426c80cd8be373c
Contents?: true
Size: 1.37 KB
Versions: 1
Compression:
Stored size: 1.37 KB
Contents
require 'integration_spec_helper' module Rmega describe 'Resumable download' do let(:download_url) { 'https://mega.co.nz/#!NYVkDaLD!BKyN5SRpOaEtGnTcwiAqcxmJc7p-k0IPWKAW-471KRE' } let(:destination_file) { "#{temp_folder}/temp.txt" } before do Thread.abort_on_exception = false allow_any_instance_of(Pool).to receive(:threads_raises_exceptions).and_return(nil) end it 'resume a download of a file' do node = Nodes::Factory.build_from_url(download_url) content = nil thread = Thread.new do node.download(destination_file) end loop do next unless File.exists?(destination_file) node.file_io_synchronize { content = File.read(destination_file) } content.strip! break if content.size > 5_000_000 sleep(1) end thread.kill sleep(1) thread = Thread.new do node.download(destination_file) end loop do # todo: i saw this failing becausa destination_file was missing :/ node.file_io_synchronize { content = File.read(destination_file) } content.strip! expect(content.size).to be > 5_000_000 break if content.size >= 15_728_640 sleep(1) end thread.join md5 = Digest::MD5.file(destination_file).hexdigest expect(md5).to eq("0451dc82ac003dbef703342e40a1b8f6") end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rmega-0.2.0 | spec/integration/resume_download_spec.rb |