Sha256: 918140671fb51df7985347aa23d71f5d13f92f1877d8e1c1943cc58787c04bdf

Contents?: true

Size: 792 Bytes

Versions: 4

Compression:

Stored size: 792 Bytes

Contents

# -*- encoding: utf-8 -*-

require 'spec_helper'

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

  it 'requires value to be present with helper' do
    input << ''
    input.rewind
    q = shell.ask("What is your name?").argument(:required)
    expect { q.read }.to raise_error(ArgumentError)
  end

  it 'requires value to be present with option' do
    input << ''
    input.rewind
    q = shell.ask("What is your name?", :required => true)
    expect { q.read }.to raise_error(ArgumentError)
  end

  it "doesn't require value to be present" do
    input << ''
    input.rewind
    q = shell.ask("What is your name?").argument(:optional)
    expect(q.read).to be_nil
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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