Skip to content

Commit 12eef0e

Browse files
committed
Test colorization in specs
1 parent d0c4ba7 commit 12eef0e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

spec/flipper/cli_spec.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616
describe "enable" do
1717
describe "feature" do
1818
it do
19-
expect(subject).to have_attributes(status: 0, stdout: /feature.*enabled/)
19+
expect(subject).to have_attributes(status: 0, stdout: /feature.*\e\[32m.*enabled/)
2020
expect(Flipper).to be_enabled(:feature)
2121
end
2222
end
2323

2424
describe "-a User;1 feature" do
2525
it do
26-
expect(subject).to have_attributes(status: 0, stdout: /feature.*enabled.*User;1/m)
26+
expect(subject).to have_attributes(status: 0, stdout: /feature.*\e\[33m.*enabled.*User;1/m)
2727
expect(Flipper).to be_enabled(:feature, Flipper::Actor.new("User;1"))
2828
end
2929
end
@@ -172,6 +172,9 @@ def run(argv)
172172
$stderr = StringIO.new
173173
status = 0
174174

175+
# Prentend this a TTY so we can test colorization
176+
allow($stdout).to receive(:tty?).and_return(true)
177+
175178
begin
176179
Flipper::CLI.run(argv)
177180
rescue SystemExit => e

0 commit comments

Comments
 (0)