1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00
pry--pry/spec/helpers/text_spec.rb
André Luis Leal Cardoso Junior 60e84ee1d8 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.
2020-10-05 21:57:25 -03:00

18 lines
605 B
Ruby

# 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