summaryrefslogtreecommitdiff
path: root/test/test_highline.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_highline.rb')
-rwxr-xr-xtest/test_highline.rb17
1 files changed, 16 insertions, 1 deletions
diff --git a/test/test_highline.rb b/test/test_highline.rb
index e623305..aeb41ca 100755
--- a/test/test_highline.rb
+++ b/test/test_highline.rb
@@ -817,13 +817,28 @@ class TestHighLine < Minitest::Test
end
def test_default_with_non_String_objects
- # With a non-string object, it should not show
+ # With a non-string object, it should try to coerce it to String.
+ # If the coercion is not possible, do not show
# any 'default' at prompt line. And should
# return the "default" object, without conversion.
@input << "\n"
@input.rewind
+ default_integer_object = 42
+
+ answer = @terminal.ask("Question: ") do |q|
+ q.default = default_integer_object
+ end
+
+ assert_equal default_integer_object, answer
+ assert_equal "Question: |42| ", @output.string
+
+ @input.truncate(@input.rewind)
+ @input << "\n"
+ @input.rewind
+ @output.truncate(@output.rewind)
+
default_non_string_object = Object.new
answer = @terminal.ask("Question: ") do |q|