Skip to content

Commit 210a8a6

Browse files
andrykonchinheadius
authored andcommitted
Fix formatting in Exception#full_message when RuntimeError is not handled and :highlight option is specified
1 parent 59dab45 commit 210a8a6

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

core/exception/full_message_spec.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,24 @@
7979
err.full_message(highlight: true).should !~ /unhandled exception/
8080
err.full_message(highlight: false).should !~ /unhandled exception/
8181
end
82+
83+
it "adds escape sequences to highlight some strings if the message is not specified and :highlight option is specified" do
84+
e = RuntimeError.new("")
85+
86+
full_message = e.full_message(highlight: true, order: :top).lines
87+
full_message[0].should.end_with? "\e[1;4munhandled exception\e[m\n"
88+
89+
full_message = e.full_message(highlight: true, order: :bottom).lines
90+
full_message[0].should == "\e[1mTraceback\e[m (most recent call last):\n"
91+
full_message[-1].should.end_with? "\e[1;4munhandled exception\e[m\n"
92+
93+
full_message = e.full_message(highlight: false, order: :top).lines
94+
full_message[0].should.end_with? "unhandled exception\n"
95+
96+
full_message = e.full_message(highlight: false, order: :bottom).lines
97+
full_message[0].should == "Traceback (most recent call last):\n"
98+
full_message[-1].should.end_with? "unhandled exception\n"
99+
end
82100
end
83101

84102
describe "generic Error" do

0 commit comments

Comments
 (0)