Sha256: 6bc27791f109b730f217ec4b1f1ffea79c8002bb80704b458112fdb257090a8b
Contents?: true
Size: 896 Bytes
Versions: 10
Compression:
Stored size: 896 Bytes
Contents
# encoding: utf-8 RSpec.describe TTY::Prompt::Question, '#default' do subject(:prompt) { TTY::TestPrompt.new } it 'uses default value' do name = 'Anonymous' prompt.input << "\n" prompt.input.rewind answer = prompt.ask('What is your name?', default: name) expect(answer).to eq(name) expect(prompt.output.string).to eq([ "What is your name? \e[90m(Anonymous)\e[0m ", "\e[1000D\e[K\e[1A", "\e[1000D\e[K", "What is your name? \e[32mAnonymous\e[0m\n" ].join) end it 'uses default value in block' do name = 'Anonymous' answer = prompt.ask('What is your name?') { |q| q.default(name) } expect(answer).to eq(name) expect(prompt.output.string).to eq([ "What is your name? \e[90m(Anonymous)\e[0m ", "\e[1000D\e[K\e[1A", "\e[1000D\e[K", "What is your name? \e[32mAnonymous\e[0m\n" ].join) end end
Version data entries
10 entries across 10 versions & 1 rubygems