diff options
author | Abinoam Praxedes Marques Jr <abinoam@gmail.com> | 2015-10-09 15:25:46 -0300 |
---|---|---|
committer | Abinoam Praxedes Marques Jr <abinoam@gmail.com> | 2015-10-09 15:25:48 -0300 |
commit | 7a337e79e2ce1507e872291307def4282ff1f8e6 (patch) | |
tree | 0c376cf9d5c4be311f8a31f47c35d71c45b85a5c /test | |
parent | 38ea035ae6866523e8a14e4e45a95b008b810c67 (diff) | |
download | highline-7a337e79e2ce1507e872291307def4282ff1f8e6.tar.gz |
Add tests for #168 - Error when paginating
Code ported from 1-7-stable branch
Diffstat (limited to 'test')
-rw-r--r-- | test/test_paginator.rb | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/test/test_paginator.rb b/test/test_paginator.rb index a6445a6..6dfa15b 100644 --- a/test/test_paginator.rb +++ b/test/test_paginator.rb @@ -27,4 +27,47 @@ class TestHighLinePaginator < Minitest::Test (45..50).map { |n| "This is line #{n}.\n"}.join, @output.string ) end + + def test_statement_lines_count_equal_to_page_at_shouldnt_paginate + @terminal.page_at = 6 + + @input << "\n" + @input.rewind + + list = "a\nb\nc\nd\ne\nf\n" + + @terminal.say(list) + assert_equal(list, @output.string) + end + + def test_statement_with_one_line_bigger_than_page_at_should_paginate + @terminal.page_at = 6 + + @input << "\n" + @input.rewind + + list = "a\nb\nc\nd\ne\nf\ng\n" + + paginated = + "a\nb\nc\nd\ne\nf\n" \ + "\n-- press enter/return to continue or q to stop -- \n\n" \ + "g\n" + + @terminal.say(list) + assert_equal(paginated, @output.string) + end + + def test_quiting_paging_shouldnt_raise + # See https://github.com/JEG2/highline/issues/168 + + @terminal.page_at = 6 + + @input << "q" + @input.rewind + + list = "a\nb\nc\nd\ne\nf\n" + + # expect not to raise an error on next line + @terminal.say(list) + end end
\ No newline at end of file |