Sha256: e346220575b81452d584e02ff363a7890cf2f4cdce0b40035ebb0350fa9350c6

Contents?: true

Size: 686 Bytes

Versions: 10

Compression:

Stored size: 686 Bytes

Contents

# encoding: utf-8

RSpec.describe TTY::Prompt, '#collect' do

  subject(:prompt) { TTY::TestPrompt.new }

  it "collects more than one answer" do
    prompt.input << "Piotr\r30\rStreet\rCity\r123\r"
    prompt.input.rewind

    result = prompt.collect do
      key(:name).ask('Name?')

      key(:age).ask('Age?', convert: :int)

      key(:address) do
        key(:street).ask('Street?', required: true)
        key(:city).ask('City?')
        key(:zip).ask('Zip?', validate: /\A\d{3}\Z/)
      end
    end

    expect(result).to include({
      name: 'Piotr',
      age: 30,
      address: {
        street: 'Street',
        city: 'City',
        zip: '123'
      }
    })
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
tty-prompt-0.12.0 spec/unit/collect_spec.rb
tty-prompt-0.11.0 spec/unit/collect_spec.rb
tty-prompt-0.10.1 spec/unit/collect_spec.rb
tty-prompt-0.10.0 spec/unit/collect_spec.rb
tty-prompt-0.9.0 spec/unit/collect_spec.rb
tty-prompt-0.8.0 spec/unit/collect_spec.rb
tty-prompt-0.7.1 spec/unit/collect_spec.rb
tty-prompt-0.7.0 spec/unit/collect_spec.rb
tty-prompt-0.6.0 spec/unit/collect_spec.rb
tty-prompt-0.5.0 spec/unit/collect_spec.rb