Sha256: 780a1f91cdf5609f76a70de8995e57cbe564f11aac3aebc5bbeda603d010e639

Contents?: true

Size: 611 Bytes

Versions: 6

Compression:

Stored size: 611 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe TTY::Shell::Question, '#character' do
  let(:input)  { StringIO.new }
  let(:output) { StringIO.new }
  let(:shell) { TTY::Shell.new(input, output) }

  it 'switches to character input' do
    input << "abcd"
    input.rewind
    q = shell.ask("Which one do you prefer a, b, c or d?").char(true)
    expect(q.character)
    expect(q.read_string).to eq("abcd")
  end

  it 'acts as reader without arguments' do
    input << "abcd"
    input.rewind
    q = shell.ask("Which one do you prefer a, b, c or d?")
    expect(q.char).to eq(false)
  end
end # character

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
tty-0.2.1 spec/tty/shell/question/character_spec.rb
tty-0.2.0 spec/tty/shell/question/character_spec.rb
tty-0.1.3 spec/tty/shell/question/character_spec.rb
tty-0.1.2 spec/tty/shell/question/character_spec.rb
tty-0.1.1 spec/tty/shell/question/character_spec.rb
tty-0.1.0 spec/tty/shell/question/character_spec.rb