diff options
author | mmihira <mmihira.w@gmail.com> | 2016-07-09 13:11:20 +1000 |
---|---|---|
committer | mmihira <mmihira.w@gmail.com> | 2016-07-09 13:11:20 +1000 |
commit | 4298414b4032752574db9bb59aac86498feb2ecc (patch) | |
tree | b60747cf2b3cc1d1c450e0fd8d7f57e437350ed5 /test | |
parent | 7d9c50ec81baa304a5144f19898505c7f3b9ae04 (diff) | |
download | highline-4298414b4032752574db9bb59aac86498feb2ecc.tar.gz |
Tests for Proc as confirm attribute. Update docs
Diffstat (limited to 'test')
-rwxr-xr-x | test/test_highline.rb | 18 |
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 |