diff options
-rw-r--r-- | lib/highline/simulate.rb | 2 | ||||
-rw-r--r-- | test/tc_simulator.rb | 10 |
2 files changed, 11 insertions, 1 deletions
diff --git a/lib/highline/simulate.rb b/lib/highline/simulate.rb index 3596f59..077d54c 100644 --- a/lib/highline/simulate.rb +++ b/lib/highline/simulate.rb @@ -23,7 +23,7 @@ class HighLine # Simulate StringIO#getbyte by shifting a single character off of the next line of the script def getbyte - line = gets + line = gets.dup if line.length > 0 char = line.slice! 0 @strings.unshift line diff --git a/test/tc_simulator.rb b/test/tc_simulator.rb index ac81748..a34f63a 100644 --- a/test/tc_simulator.rb +++ b/test/tc_simulator.rb @@ -20,4 +20,14 @@ class SimulatorTest < Test::Unit::TestCase assert_equal '18', age end end + + def test_simulate_with_echo_and_frozen_strings + HighLine::Simulate.with('the password'.freeze) do + password = ask('What is your password?') do |q| + q.echo = '*' + end + + assert_equal 'the password', password + end + end end
\ No newline at end of file |