Skip to content

Commit

Permalink
Add testing code for calling #detailed_message
Browse files Browse the repository at this point in the history
  • Loading branch information
ksss committed Mar 30, 2023
1 parent 857e7e3 commit 23d8981
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/test_rake_application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,33 @@ def test_display_exception_details
assert_match __method__.to_s, err
end

if Exception.method_defined?(:detailed_message)
def test_display_exception_details_with_detailed_message
error_class = Class.new(StandardError) do
def detailed_message(**)
"detailed_message!!"
end
end

begin
raise error_class
rescue error_class => ex
end

out, err = capture_io do
@app.set_default_options # reset trace output IO

@app.display_error_message ex
end

assert_empty out

assert_match "rake aborted!", err
assert_match "detailed_message!!", err
assert_match __method__.to_s, err
end
end

def test_display_exception_details_bad_encoding
begin
raise "El Niño is coming!".dup.force_encoding("US-ASCII")
Expand Down

0 comments on commit 23d8981

Please sign in to comment.