Sha256: 7fb71def13040bac92b82cd818340210f8bf33b961c835352030f184a7eb0583

Contents?: true

Size: 573 Bytes

Versions: 5

Compression:

Stored size: 573 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 eql 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 eql name
  end
end # default

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
tty-0.0.11 spec/tty/shell/question/default_spec.rb
tty-0.0.10 spec/tty/shell/question/default_spec.rb
tty-0.0.9 spec/tty/shell/question/default_spec.rb
tty-0.0.8 spec/tty/shell/question/default_spec.rb
tty-0.0.7 spec/tty/shell/question/default_spec.rb