summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbinoam P. Marques Jr <abinoam@gmail.com>2022-12-31 22:14:47 -0300
committerAbinoam P. Marques Jr <abinoam@gmail.com>2022-12-31 22:14:47 -0300
commitb999371c828c73d17b96fbb30a55a86c9ac861ef (patch)
tree3602a820340daa27f40c03c1369b05f747b87b7a
parent33cee8a7a7946e27b3be8459721f69c73eee7694 (diff)
downloadhighline-b999371c828c73d17b96fbb30a55a86c9ac861ef.tar.gz
Add test for issue #249
-rwxr-xr-xtest/test_highline.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/test_highline.rb b/test/test_highline.rb
index 67d8fad..e623305 100755
--- a/test/test_highline.rb
+++ b/test/test_highline.rb
@@ -1358,6 +1358,25 @@ class TestHighLine < Minitest::Test
"? ", @output.string)
end
+ def test_range_requirements_with_array_of_strings
+ @input.truncate(@input.rewind)
+ @input << "z\nx\nb\n"
+ @input.rewind
+ @output.truncate(@output.rewind)
+
+ answer = @terminal.ask("Letter a, b, or c? ") do |q|
+ q.in = %w[ a b c ]
+ end
+ assert_equal("b", answer)
+ assert_equal("Letter a, b, or c? " \
+ "Your answer isn't within the expected range " \
+ "(included in [\"a\", \"b\", \"c\"]).\n" \
+ "? " \
+ "Your answer isn't within the expected range " \
+ "(included in [\"a\", \"b\", \"c\"]).\n" \
+ "? ", @output.string)
+ end
+
def test_reask
number = 61_676
@input << "Junk!\n" << number << "\n"