summaryrefslogtreecommitdiff
path: root/test/test_wrapper.rb
diff options
context:
space:
mode:
authorAbinoam Praxedes Marques Jr <abinoam@gmail.com>2015-03-13 18:59:37 -0300
committerAbinoam Praxedes Marques Jr <abinoam@gmail.com>2015-04-29 23:43:25 -0300
commitfdfcf64eb991397721665bb749a32079e199ef90 (patch)
treeae960d63bd0995a58af1b3889c379d60ef229150 /test/test_wrapper.rb
parent28ea6e726b9d9257e428bf91d98a0a7c5f266200 (diff)
downloadhighline-fdfcf64eb991397721665bb749a32079e199ef90.tar.gz
Split each wrapper test in its own method
Diffstat (limited to 'test/test_wrapper.rb')
-rw-r--r--test/test_wrapper.rb23
1 files changed, 12 insertions, 11 deletions
diff --git a/test/test_wrapper.rb b/test/test_wrapper.rb
index c585969..062d6fa 100644
--- a/test/test_wrapper.rb
+++ b/test/test_wrapper.rb
@@ -1,22 +1,23 @@
require "minitest/autorun"
require "test_helper"
-class TestHighLine < Minitest::Test
+require "highline"
+
+class TestHighLineWrapper < Minitest::Test
def setup
HighLine.reset
@input = StringIO.new
@output = StringIO.new
@terminal = HighLine.new(@input, @output)
- end
-
- def test_wrap
@terminal.wrap_at = 80
+ end
- @terminal.say("This is a very short line.")
+ def test_dont_wrap_if_line_is_shorter_than_wrap_at
+ @terminal.say("This is a very short line.\n")
assert_equal("This is a very short line.\n", @output.string)
+ end
- @output.truncate(@output.rewind)
-
+ def test_wrap_long_lines_correctly
long_line =
"This is a long flowing paragraph meant to span " +
"several lines. This text should definitely be " +
@@ -34,9 +35,9 @@ class TestHighLine < Minitest::Test
@terminal.say long_line
assert_equal wrapped_long_line, @output.string
+ end
- @output.truncate(@output.rewind)
-
+ def test_dont_wrap_already_well_wrapped_text
well_formatted_text =
" * This is a simple embedded list.\n" +
" * You're code should not mess with this...\n" +
@@ -45,9 +46,9 @@ class TestHighLine < Minitest::Test
@terminal.say well_formatted_text
assert_equal well_formatted_text, @output.string
+ end
- @output.truncate(@output.rewind)
-
+ def test_wrap_single_word_longer_than_wrap_at
@terminal.say("-=" * 50)
assert_equal(("-=" * 40 + "\n") + ("-=" * 10 + "\n"), @output.string)
end