diff options
author | Kyrylo Silin <silin@kyrylo.org> | 2021-03-28 00:54:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-28 00:54:54 +0200 |
commit | 033f69b3afcce57ed8d8b68f297457d1a80b1e6c (patch) | |
tree | b070de1852c7ca872e038b73179b21775829a155 /spec | |
parent | 438ce376b0b0f1ca501d6a712d1b26ca0dde5c15 (diff) | |
parent | 8e8f2d53d6972e3a96fd0c63b64b9e626d438b83 (diff) | |
download | pry-033f69b3afcce57ed8d8b68f297457d1a80b1e6c.tar.gz |
Merge pull request #2158 from andrehjr/fix-color-off-overwrite
Fix breakage in output with colors disabled
Diffstat (limited to 'spec')
-rw-r--r-- | spec/helpers/text_spec.rb | 18 | ||||
-rw-r--r-- | spec/pry_repl_spec.rb | 2 |
2 files changed, 19 insertions, 1 deletions
diff --git a/spec/helpers/text_spec.rb b/spec/helpers/text_spec.rb new file mode 100644 index 00000000..e45bc8ab --- /dev/null +++ b/spec/helpers/text_spec.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +describe Pry::Helpers::Text do + describe "#strip_color" do + [ + ["\e[1A\e[0G[2] pry(main)> puts \e[31m\e[1;31m'\e[0m\e[31m"\ + "hello\e[1;31m'\e[0m\e[31m\e[0m\e[1B\e[0G", + "\e[1A\e[0G[2] pry(main)> puts 'hello'\e[1B\e[0G"], + ["\e[31m\e[1;31m'\e[0m\e[31mhello\e[1;31m'\e[0m\e[31m\e[0m\e[1B\e[0G", + "'hello'\e[1B\e[0G"], + %w[string string] + ].each do |(text, text_without_color)| + it "removes color code from text #{text.inspect}" do + expect(subject.strip_color(text)).to eql(text_without_color) + end + end + end +end diff --git a/spec/pry_repl_spec.rb b/spec/pry_repl_spec.rb index 946b92e8..b7f5870a 100644 --- a/spec/pry_repl_spec.rb +++ b/spec/pry_repl_spec.rb @@ -135,7 +135,7 @@ loop do break #note the tab here end TAB - output("do\n break #note the tab here\nend\n\e[1B\e[0G=> nil") + output("do\n break #note the tab here\nend\n\e\\[1B\e\\[0G=> nil") end end end |