Sha256: 0d2df957152c89a5379ca3e8ec985bae552c743f90d19b2f6357cd6eba893427

Contents?: true

Size: 982 Bytes

Versions: 2

Compression:

Stored size: 982 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

2 entries across 2 versions & 1 rubygems

Version Path
tty-progressbar-0.14.0 spec/unit/resize_spec.rb
tty-progressbar-0.13.0 spec/unit/resize_spec.rb