Sha256: 1fbf695325c258c72aa386834b93880e958d8852d0f9c35f52b9fbc04fe3fea9
Contents?: true
Size: 601 Bytes
Versions: 8
Compression:
Stored size: 601 Bytes
Contents
# encoding: utf-8 RSpec.describe TTY::ProgressBar, 'custom formatter' do let(:output) { StringIO.new('', 'w+') } it "allows for custom tag" do progress = TTY::ProgressBar.new(":hi", output: output, total: 10) stub_const("HiFormatter", Class.new do def initialize(progress) @progress = progress end def matches?(value) value.to_s =~ /:hi/ end def format(value) value.gsub(/:hi/, "Hello") end end) progress.use(HiFormatter) progress.advance output.rewind expect(output.read).to eq("\e[1GHello") end end
Version data entries
8 entries across 8 versions & 1 rubygems