Sha256: af5d302365169972c69f1465939a5795a9255622f1036911c414c3495a9ce929
Contents?: true
Size: 1.08 KB
Versions: 2
Compression:
Stored size: 1.08 KB
Contents
# encoding: utf-8 RSpec.describe 'Custom Printer' do let(:output) { StringIO.new } before do stub_const('CustomPrinter', Class.new(TTY::Command::Printers::Abstract) do def write(message) output << message end end) end it "prints command start" do printer = CustomPrinter.new(output) cmd = TTY::Command::Cmd.new(:echo, "'hello world'") printer.print_command_start(cmd) output.rewind expect(output.string).to eq("echo \\'hello\\ world\\'") end it "prints command stdout data" do printer = CustomPrinter.new(output) cmd = TTY::Command::Cmd.new(:echo, 'hello world') printer.print_command_out_data(cmd, 'data') output.rewind expect(output.string).to eq("data") end it "prints command exit" do printer = CustomPrinter.new(output) cmd = TTY::Command::Cmd.new(:echo, 'hello world') printer.print_command_exit(cmd) output.rewind expect(output.string).to be_empty end it "accepts options" do printer = CustomPrinter.new(output, foo: :bar) expect(printer.options[:foo]).to eq(:bar) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
tty-command-0.9.0 | spec/unit/printers/custom_spec.rb |
tty-command-0.8.2 | spec/unit/printers/custom_spec.rb |