Repository: JEG2/highline (Ruby)

Issue:
Menu prompt not reused after failed menu selection
``` ruby
requre 'highline/import'
choose do | menu |
  menu.prompt = "> "
  menu.choice :exit, "Exit cube editor" do
    abort("Exiting")
  end
end
```

After a failed selection the promt defaults to '?  '
I hope I'm not missing something in the API.



Discussion:
I have confirmed the behavior in my setup.
I'll be taking a look at it.

Dear @strigonLeader,

I'm sorry but you're right, this particular need has no intuitive way of doing it.

Reviewing the code I could see that, when "reasking" the question in the face of an error HighLine doesn't show the prompt you set up. Instead, it shows the `responses[:ask_on_error]` string.
And... for menus, there were no easy way to overwrite it.
I have made a simple workaround in a PR that I'm pushing that allows it to be overwritten.

You should add the following line inside the configuration block.

``` ruby
menu.responses[:ask_on_error] = "> "
```

So your complete example would be:

``` ruby
require 'highline/import'

choose do |menu|
  menu.prompt = "> "
  menu.responses[:ask_on_error] = "> "
  menu.choice :exit, "Exit cube editor" do
    abort("Exiting")
  end
end
```

When I have more time I will rework this to something more straightforward.




Patch:
diff --git a/Changelog.md b/Changelog.md
index 0252073d..fb959624 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -2,6 +2,9 @@
 
 Below is a complete listing of changes for each revision of HighLine.
 
+### 2.0.0-develop.5 / 2015-12-27
+* Fix #180 with PR #181 - Make it possible to overwrite the menu prompt shown on errors.
+
 ### 2.0.0-develop.4 / 2015-12-14
 This versions makes the code documentation 100% 'A' grade on inch.
 We have used inch and http://inch-ci.org to guide the priorities
diff --git a/lib/highline/menu.rb b/lib/highline/menu.rb
index 3e8f5b0d..e0c18de6 100644
--- a/lib/highline/menu.rb
+++ b/lib/highline/menu.rb
@@ -425,12 +425,10 @@ def to_s(  )
     # This method will update the intelligent responses to account for
     # Menu specific differences.  Calls the superclass' (Question's)
     # build_responses method, overriding its default arguments to specify
-    # 'options' will be used to populate choice lists, and that
-    # the newly built hash will predominate over the preexisting hash
-    # for any keys that are the same.
+    # 'options' will be used to populate choice lists.
     #
-    def update_responses(  )
-      build_responses(options, true)
+    def update_responses
+      build_responses(options)
     end
   end
 end
diff --git a/lib/highline/version.rb b/lib/highline/version.rb
index 9c8315ca..79776605 100644
--- a/lib/highline/version.rb
+++ b/lib/highline/version.rb
@@ -2,5 +2,5 @@
 
 class HighLine
   # The version of the installed library.
-  VERSION = "2.0.0-develop.4".freeze
+  VERSION = "2.0.0-develop.5".freeze
 end


Test patch:
diff --git a/test/test_menu.rb b/test/test_menu.rb
index 5edcb03f..594f622b 100644
--- a/test/test_menu.rb
+++ b/test/test_menu.rb
@@ -439,4 +439,23 @@ def test_cancel_paging
     assert( @output.string !~ /q to stop.*q to stop/m,
             "Paging message appeared more than once." )
   end
+
+  # Issue #180 - https://github.com/JEG2/highline/issues/180
+  def test_menu_prompt
+    @input << "2\n1\n"
+    @input.rewind
+
+    selected = @terminal.choose do |menu|
+      menu.responses[:ask_on_error] = "> "
+      menu.prompt = "> "
+      menu.choice :exit, "Exit cube editor"
+    end
+
+    prompt = "> "
+    first_asking = "1. exit\n"
+    error_message = "You must choose one of [1, exit].\n"
+    complete_interaction = first_asking + prompt + error_message + prompt # Same prompt when repeating question
+
+    assert_equal complete_interaction, @output.string
+  end
 end