summaryrefslogtreecommitdiff
path: root/test/test_menu.rb
diff options
context:
space:
mode:
authormatrinox <geofflee21@me.com>2016-01-24 21:06:56 -0800
committerAbinoam Praxedes Marques Jr <abinoam@gmail.com>2016-02-19 03:57:18 -0300
commit08f7451a9554df8ca2a165c153011844ad46f9e0 (patch)
treecc794da112e75bf38fb61d6faa9db273926c5468 /test/test_menu.rb
parentdb74d876215d9ba1ac82ea21d38475fb27e1677c (diff)
downloadhighline-08f7451a9554df8ca2a165c153011844ad46f9e0.tar.gz
Fix bug with responses hash not updating with each additional menu choice
Originally, build_responses gave precedence to new hash (which makes sense) but then old hash was given precedence because it allowed the user to set things and let that stick Instead, the solution should be to split the concerns: one hash for user one hash for internal. The hashes are then merged when outputting, giving the user responses precedence This does have the side effect of taking away responses reflection on the side of the client but that is easily added in build_responses
Diffstat (limited to 'test/test_menu.rb')
-rw-r--r--test/test_menu.rb20
1 files changed, 19 insertions, 1 deletions
diff --git a/test/test_menu.rb b/test/test_menu.rb
index 1a53f28..2bcd824 100644
--- a/test/test_menu.rb
+++ b/test/test_menu.rb
@@ -440,7 +440,6 @@ class TestMenu < Minitest::Test
assert_equal(selected, 3)
end
-
def test_cancel_paging
# Tests that paging can be cancelled halfway through
@terminal.page_at = 5
@@ -460,6 +459,25 @@ class TestMenu < Minitest::Test
"Paging message appeared more than once." )
end
+ def test_autocomplete_prompt
+ @input << "lisp\nRuby\n"
+ @input.rewind
+
+ answer = @terminal.choose do |menu|
+ menu.choice(:Perl)
+ menu.choice(:Python)
+ menu.choice(:Ruby)
+ menu.prompt = "What is your favorite programming language? "
+ end
+ languages = [:Perl, :Python, :Ruby]
+ assert_equal("1. Perl\n" +
+ "2. Python\n" +
+ "3. Ruby\n" +
+ "What is your favorite programming language? " +
+ "You must choose one of [1, 2, 3, Perl, Python, Ruby].\n" +
+ "? ", @output.string )
+ end
+
# Issue #180 - https://github.com/JEG2/highline/issues/180
def test_menu_prompt
@input << "2\n1\n"