Sha256: 4dbe9168970d3d8a7317809b4b8a323d3a091d10d2a7459b9764fc093a274a0e

Contents?: true

Size: 565 Bytes

Versions: 6

Compression:

Stored size: 565 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

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

  it 'uses default value' do
    name = 'Anonymous'
    q = shell.ask("What is your name?").default(name)
    answer = q.read
    expect(answer).to eq(name)
  end

  it 'uses default value in block' do
    name = 'Anonymous'
    q = shell.ask "What is your name?" do
      default name
    end
    answer = q.read
    expect(answer).to eq(name)
  end
end # default

Version data entries

6 entries across 6 versions & 1 rubygems

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