Sha256: 04844a7eee0127322c23c8153877dbd307f8e626e48afca5c9f7d0ca69eb2c6a
Contents?: true
Size: 1.26 KB
Versions: 15
Compression:
Stored size: 1.26 KB
Contents
# encoding: utf-8 RSpec.describe TTY::Prompt::Question, '#modify' do subject(:prompt) { TTY::TestPrompt.new } it 'preserves answer for unkown modification' do prompt.input << 'piotr' prompt.input.rewind answer = prompt.ask("What is your name?") { |q| q.modify(:none) } expect(answer).to eq('piotr') end it 'converts to upper case' do prompt.input << 'piotr' prompt.input.rewind answer = prompt.ask("What is your name?") { |q| q.modify(:upcase) } expect(answer).to eq('PIOTR') end it 'trims whitespace' do prompt.input << " Some white\t space\t \there! \n" prompt.input.rewind answer = prompt.ask('Enter some text: ') { |q| q.modify(:trim) } expect(answer).to eq("Some white\t space\t \there!") end it 'collapses whitespace' do prompt.input << " Some white\t space\t \there! \n" prompt.input.rewind answer = prompt.ask('Enter some text: ') { |q| q.modify(:collapse) } expect(answer).to eq(' Some white space here! ') end it 'strips and collapses whitespace' do prompt.input << " Some white\t space\t \there! \n" prompt.input.rewind answer = prompt.ask('Enter some text: ') { |q| q.modify(:strip, :collapse) } expect(answer).to eq('Some white space here!') end end
Version data entries
15 entries across 15 versions & 1 rubygems