summaryrefslogtreecommitdiff
path: root/test/test_wrapper.rb
diff options
context:
space:
mode:
authorAbinoam Praxedes Marques Jr <abinoam@gmail.com>2015-03-13 18:32:05 -0300
committerAbinoam Praxedes Marques Jr <abinoam@gmail.com>2015-04-29 23:43:25 -0300
commit753eb608b5e7ac1117a0da64252f3c583c3a8178 (patch)
tree58a9405227f126b0e4cc4c0c744f8df31dbe9154 /test/test_wrapper.rb
parent850c9ed22f48b336b72d120a81bbce518d0140a2 (diff)
downloadhighline-753eb608b5e7ac1117a0da64252f3c583c3a8178.tar.gz
Move HighLine::Wrapper tests to its own file
Diffstat (limited to 'test/test_wrapper.rb')
-rw-r--r--test/test_wrapper.rb45
1 files changed, 45 insertions, 0 deletions
diff --git a/test/test_wrapper.rb b/test/test_wrapper.rb
new file mode 100644
index 0000000..c52888f
--- /dev/null
+++ b/test/test_wrapper.rb
@@ -0,0 +1,45 @@
+require "minitest/autorun"
+require "test_helper"
+
+class TestHighLine < 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
+
+ @terminal.say("This is a very short line.")
+ assert_equal("This is a very short line.\n", @output.string)
+
+ @output.truncate(@output.rewind)
+
+ @terminal.say( "This is a long flowing paragraph meant to span " +
+ "several lines. This text should definitely be " +
+ "wrapped at the set limit, in the result. Your code " +
+ "does well with things like this.\n\n" +
+ " * This is a simple embedded list.\n" +
+ " * You're code should not mess with this...\n" +
+ " * Because it's already formatted correctly and " +
+ "does not\n" +
+ " exceed the limit!" )
+ assert_equal( "This is a long flowing paragraph meant to span " +
+ "several lines. This text should\n" +
+ "definitely be wrapped at the set limit, in the " +
+ "result. Your code does well with\n" +
+ "things like this.\n\n" +
+ " * This is a simple embedded list.\n" +
+ " * You're code should not mess with this...\n" +
+ " * Because it's already formatted correctly and does " +
+ "not\n" +
+ " exceed the limit!\n", @output.string )
+
+ @output.truncate(@output.rewind)
+
+ @terminal.say("-=" * 50)
+ assert_equal(("-=" * 40 + "\n") + ("-=" * 10 + "\n"), @output.string)
+ end
+end \ No newline at end of file