Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2158 from andrehjr/fix-color-off-overwrite
Fix breakage in output with colors disabled
- Loading branch information
Showing
3 changed files
with
20 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters