spec/shelly/client_spec.rb in shelly-0.4.30 vs spec/shelly/client_spec.rb in shelly-0.4.31
- old
+ new
@@ -350,10 +350,11 @@
before do
@filename = "2011.11.26.04.00.10.foo.postgres.tar.gz"
@url = "https://#{CGI.escape(email)}:#{api_key}@backup.example.com/file.gz"
response = Net::HTTPResponse.new('', '', '')
# Streaming
+ response.stub(:to_hash).and_return({'file-size' => ['1000']})
response.stub(:read_body).and_yield("aaa").and_yield("bbbbb").and_yield("dddf")
FakeWeb.register_uri(:get, @url, :response => response)
end
it "should write streamed data to file" do
@@ -361,14 +362,14 @@
File.read(@filename).should == %w(aaa bbbbb dddf).join
end
it "should execute progress_callback with size of every chunk" do
progress = mock(:update => true)
- progress.should_receive(:update).with(3)
- progress.should_receive(:update).with(5)
- progress.should_receive(:update).with(4)
+ progress.should_receive(:update).with(3, 1000)
+ progress.should_receive(:update).with(5, 1000)
+ progress.should_receive(:update).with(4, 1000)
- callback = lambda { |size| progress.update(size) }
+ callback = lambda { |size, total| progress.update(size, total) }
@client.download_file("foo", @filename, @url, callback)
end
end