From 60e84ee1d80919b0cc41268a878ffc9e78f903ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Luis=20Leal=20Cardoso=20Junior?= Date: Sun, 30 Aug 2020 19:56:16 -0300 Subject: Make #strip_color only remove colors. The previous implementation was removing more than that. When Pry.color = false, it was messing up the output of a few commands. --- spec/helpers/text_spec.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 spec/helpers/text_spec.rb (limited to 'spec') 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 -- cgit v1.2.1