summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authormmihira <mmihira.w@gmail.com>2016-07-09 13:11:20 +1000
committermmihira <mmihira.w@gmail.com>2016-07-09 13:11:20 +1000
commit4298414b4032752574db9bb59aac86498feb2ecc (patch)
treeb60747cf2b3cc1d1c450e0fd8d7f57e437350ed5 /test
parent7d9c50ec81baa304a5144f19898505c7f3b9ae04 (diff)
downloadhighline-4298414b4032752574db9bb59aac86498feb2ecc.tar.gz
Tests for Proc as confirm attribute. Update docs
Diffstat (limited to 'test')
-rwxr-xr-xtest/test_highline.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/test_highline.rb b/test/test_highline.rb
index a75c143..9cdfeb4 100755
--- a/test/test_highline.rb
+++ b/test/test_highline.rb
@@ -579,6 +579,24 @@ class TestHighLine < Minitest::Test
assert_equal( "Enter a filename: " +
"Are you sure you want to overwrite junk.txt? ",
@output.string )
+
+ @input.truncate(@input.rewind)
+ @input << "junk.txt\nyes\nsave.txt\nn\n"
+ @input.rewind
+ @output.truncate(@output.rewind)
+
+ scoped_variable = { "junk.txt" => '20mb' }
+ answer = @terminal.ask("Enter a filename: ") do |q|
+ q.confirm = Proc.new do |answer|
+ "Are you sure you want to overwrite #{answer} with size " +
+ "of #{scoped_variable[answer]}? "
+ end
+ end
+ assert_equal("junk.txt", answer)
+ assert_equal( "Enter a filename: " +
+ "Are you sure you want to overwrite junk.txt " +
+ "with size of 20mb? ",
+ @output.string )
end
def test_generic_confirm_with_true