Sha256: 0a8ac74a052a285188d426003b8374ac33874ffe28dfdd19adcd6031f838b25b

Contents?: true

Size: 712 Bytes

Versions: 7

Compression:

Stored size: 712 Bytes

Contents

# encoding: utf-8

RSpec.describe TTY::Prompt::Reader, '#read_line' do
  let(:input)  { StringIO.new }
  let(:output) { StringIO.new }

  subject(:reader) { described_class.new(input, output) }

  it 'masks characters' do
    mask = '*'
    input << "password\n"
    input.rewind
    answer = reader.read_line(mask)
    expect(answer).to eq("password")
  end

  it "echoes characters back" do
    input << "password\n"
    input.rewind
    answer = reader.read_line
    expect(answer).to eq("password")
    expect(output.string).to eq("")
  end

  it 'deletes characters when backspace pressed' do
    input << "aa\ba\bcc"
    input.rewind
    answer = reader.read_line
    expect(answer).to eq('acc')
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
tty-prompt-0.8.0 spec/unit/reader/read_line_spec.rb
tty-prompt-0.7.1 spec/unit/reader/read_line_spec.rb
tty-prompt-0.7.0 spec/unit/reader/read_line_spec.rb
tty-prompt-0.6.0 spec/unit/reader/read_line_spec.rb
tty-prompt-0.5.0 spec/unit/reader/read_line_spec.rb
tty-prompt-0.4.0 spec/unit/reader/read_line_spec.rb
tty-prompt-0.3.0 spec/unit/reader/read_line_spec.rb