Skip to content

Commit 23d8981

Browse files
committed
Add testing code for calling #detailed_message
1 parent 857e7e3 commit 23d8981

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

test/test_rake_application.rb

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,33 @@ def test_display_exception_details
6060
assert_match __method__.to_s, err
6161
end
6262

63+
if Exception.method_defined?(:detailed_message)
64+
def test_display_exception_details_with_detailed_message
65+
error_class = Class.new(StandardError) do
66+
def detailed_message(**)
67+
"detailed_message!!"
68+
end
69+
end
70+
71+
begin
72+
raise error_class
73+
rescue error_class => ex
74+
end
75+
76+
out, err = capture_io do
77+
@app.set_default_options # reset trace output IO
78+
79+
@app.display_error_message ex
80+
end
81+
82+
assert_empty out
83+
84+
assert_match "rake aborted!", err
85+
assert_match "detailed_message!!", err
86+
assert_match __method__.to_s, err
87+
end
88+
end
89+
6390
def test_display_exception_details_bad_encoding
6491
begin
6592
raise "El Niño is coming!".dup.force_encoding("US-ASCII")

0 commit comments

Comments
 (0)