Sha256: c9c9424096d1a8b675a3b12980f4c485bf3e3891ec05779db10590523002c665
Contents?: true
Size: 955 Bytes
Versions: 6
Compression:
Stored size: 955 Bytes
Contents
# encoding: utf-8 RSpec.describe TTY::ProgressBar, ':mean_rate token' do let(:output) { StringIO.new('', 'w+') } before { Timecop.safe_mode = false } it "shows current rate per sec" do time_now = Time.local(2014, 10, 5, 12, 0, 0) Timecop.freeze(time_now) progress = TTY::ProgressBar.new(":mean_rate", output: output, total: 100, interval: 1) # Generate a serie of advances at 2s intervals # t+0 advance=0 total=0 # t+2 advance=10 total=10 # t+4 advance=20 total=30 # t+6 advance=30 total=60 # t+8 advance=40 total=100 5.times do |i| time_now = Time.local(2014, 10, 5, 12, 0, i * 2) Timecop.freeze(time_now) progress.advance(i * 10) end output.rewind expect(output.read).to eq([ "\e[1G 0.00", "\e[1G 5.00", "\e[1G 7.50", "\e[1G10.00", "\e[1G12.50\n" ].join) Timecop.return end end
Version data entries
6 entries across 6 versions & 1 rubygems