Sha256: 4134c691c22e4fd5d0a5c94777709f4708a10490fce0a264b6ffe638cd45f16a

Contents?: true

Size: 1.15 KB

Versions: 2

Compression:

Stored size: 1.15 KB

Contents

# encoding: utf-8

RSpec.describe TTY::Command::Printers::Progress do
  let(:output) { StringIO.new }

  it "doesn't print command start" do
    printer = TTY::Command::Printers::Progress.new(output)
    cmd = TTY::Command::Cmd.new(:echo, 'hello')

    printer.print_command_start(cmd)
    output.rewind

    expect(output.string).to be_empty
  end

  it "doesn't print command stdout data" do
    printer = TTY::Command::Printers::Progress.new(output)
    cmd = TTY::Command::Cmd.new(:echo, 'hello')

    printer.print_command_out_data(cmd, 'hello', 'world')
    output.rewind

    expect(output.string).to be_empty
  end

  it "prints successful command exit in color" do
    printer = TTY::Command::Printers::Progress.new(output)
    cmd = TTY::Command::Cmd.new(:echo, 'hello')

    printer.print_command_exit(cmd, 0, 5.321)
    output.rewind

    expect(output.string).to eq("\e[32m.\e[0m")
  end

  it "prints failure command exit in color" do
    printer = TTY::Command::Printers::Progress.new(output)
    cmd = TTY::Command::Cmd.new(:echo, 'hello')

    printer.print_command_exit(cmd, 1, 5.321)
    output.rewind

    expect(output.string).to eq("\e[31mF\e[0m")
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tty-command-0.9.0 spec/unit/printers/progress_spec.rb
tty-command-0.8.2 spec/unit/printers/progress_spec.rb