Sha256: 1b90101828fa3de5b0b483081352222fbb9abdb4e7757ac426dce60264eaec20

Contents?: true

Size: 699 Bytes

Versions: 3

Compression:

Stored size: 699 Bytes

Contents

# coding: utf-8

require 'spec_helper'

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

  it "handles width exceeding terminal width" do
    progress = TTY::ProgressBar.new "[:bar]" do |config|
      config.output = output
      config.total = 5
      config.width = 1024
    end
    screen = double(:screen, width: 20)
    allow(TTY::Screen).to receive(:new).and_return(screen)
    5.times { progress.advance }
    output.rewind
    expect(output.read).to eq([
      "\e[1G[====              ]",
      "\e[1G[=======           ]",
      "\e[1G[===========       ]",
      "\e[1G[==============    ]",
      "\e[1G[==================]\n"
    ].join)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tty-progressbar-0.5.0 spec/unit/width_spec.rb
tty-progressbar-0.4.0 spec/unit/width_spec.rb
tty-progressbar-0.3.0 spec/unit/width_spec.rb