Sha256: 387c8d7e89a268ad3a8968e39c32af743ef2d81f4fdc29aa8dbf0344b3017f00

Contents?: true

Size: 989 Bytes

Versions: 4

Compression:

Stored size: 989 Bytes

Contents

RSpec.describe TTY::ProgressBar::Multi, '#reset' do
  let(:output) { StringIO.new('', 'w+') }

  it "leaves multibar state alone" do
    main = TTY::ProgressBar::Multi.new("", output: output, total: 10)
    progress = main.register("[:bar]")
    progress.advance(10)
    expect(progress.complete?).to be(true)
    progress.reset
    expect(progress.complete?).to be(false)
    progress.advance(10)
    output.rewind

    top    = TTY::ProgressBar::Multi::DEFAULT_INSET[:top]
    bottom = TTY::ProgressBar::Multi::DEFAULT_INSET[:bottom]

    progress_updates =
      output.read.scan(/#{Regexp.escape top}|#{Regexp.escape bottom}/)
    expect(progress_updates.shift).to match(top)
    expect(progress_updates.shift).to match(top)
    expect(progress_updates.shift).to match(bottom)
    expect(progress_updates.shift).to match(bottom)
    expect(progress_updates.shift).to match(bottom)
    expect(progress_updates.shift).to match(bottom)

    expect(progress_updates).to be_empty
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tty-progressbar-0.17.0 spec/unit/multi/reset_spec.rb
tty-progressbar-0.16.0 spec/unit/multi/reset_spec.rb
tty-progressbar-0.15.1 spec/unit/multi/reset_spec.rb
tty-progressbar-0.15.0 spec/unit/multi/reset_spec.rb