Sha256: aaa3233c1f67515864e771a86d7df84786fe32641cc2a132f9298df8427528e8

Contents?: true

Size: 987 Bytes

Versions: 4

Compression:

Stored size: 987 Bytes

Contents

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

  it "resizes output down by x2" do
    progress = TTY::ProgressBar.new("[:bar]", output: output, total: 5, width: 10)
    2.times { progress.advance }
    progress.resize(5)
    3.times { progress.advance }
    output.rewind
    expect(output.read).to eq([
      "\e[1G[==        ]",
      "\e[1G[====      ]",
      "\e[0m\e[2K\e[1G",
      "\e[1G[===  ]     ",
      "\e[1G[==== ]",
      "\e[1G[=====]\n"
    ].join)
  end

  it "resizes output up by x2" do
    progress = TTY::ProgressBar.new("[:bar]", output: output, total: 5, width: 10)
    2.times { progress.advance }
    progress.resize(20)
    3.times { progress.advance }
    output.rewind
    expect(output.read).to eq([
      "\e[1G[==        ]",
      "\e[1G[====      ]",
      "\e[0m\e[2K\e[1G",
      "\e[1G[============        ]",
      "\e[1G[================    ]",
      "\e[1G[====================]\n"
    ].join)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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