Sha256: adf64f9817196a0682a20b326386c5e3de0c0271a3b5418c2cca0e2805d806cf
Contents?: true
Size: 988 Bytes
Versions: 14
Compression:
Stored size: 988 Bytes
Contents
# encoding: utf-8 RSpec.describe TTY::Prompt::Question, 'convert numbers' do subject(:prompt) { TTY::TestPrompt.new } it 'fails to convert integer' do prompt.input << 'invalid' prompt.input.rewind expect { prompt.ask("What temparture?", convert: :int) }.to raise_error(TTY::Prompt::ConversionError) end it 'converts integer' do prompt.input << 35 prompt.input.rewind answer = prompt.ask("What temperature?", convert: :int) expect(answer).to be_a(Integer) expect(answer).to eq(35) end it 'fails to convert float' do prompt.input << 'invalid' prompt.input.rewind expect { prompt.ask("How tall are you?", convert: :float) }.to raise_error(TTY::Prompt::ConversionError) end it 'converts float' do number = 6.666 prompt.input << number prompt.input.rewind answer = prompt.ask('How tall are you?', convert: :float) expect(answer).to be_a(Float) expect(answer).to eq(number) end end
Version data entries
14 entries across 14 versions & 1 rubygems