summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbinoam P. Marques Jr <abinoam@gmail.com>2017-05-08 07:44:29 -0300
committerGitHub <noreply@github.com>2017-05-08 07:44:29 -0300
commitaee55bb89d381caff2104db66fc4ff667296799c (patch)
tree6d9d545fccdf8e40da5a09f3702d261ecfaa10ad
parentaddfbaf7d1f0a3c72875c3ddee76af4330b32675 (diff)
parent91d8475228b0112b802ab230a20de009a1475973 (diff)
downloadhighline-aee55bb89d381caff2104db66fc4ff667296799c.tar.gz
Merge pull request #210 from ivgiuliani/fix-frozen-strings
Do not attempt to change frozen strings
-rw-r--r--lib/highline/simulate.rb2
-rw-r--r--test/tc_simulator.rb10
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