summaryrefslogtreecommitdiff
path: root/test/test_answer_converter.rb
blob: 47bf33cbc5155c87344c30928b4172947d662906 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env ruby
# coding: utf-8

require "test_helper"

require "highline/question"

class TestAnswerConverter < Minitest::Test
  def test_integer_convertion
    question = HighLine::Question.new("What's your age?", Integer)
    question.answer = "18"
    answer_converter = HighLine::Question::AnswerConverter.new(question)

    refute_equal "18", answer_converter.convert
    assert_equal 18, answer_converter.convert
  end

  def test_float_convertion
    question = HighLine::Question.new("Write PI", Float)
    question.answer = "3.14159"
    answer_converter = HighLine::Question::AnswerConverter.new(question)

    refute_equal "3.14159", answer_converter.convert
    assert_equal 3.14159, answer_converter.convert
  end
end