-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow non-exception objects to be passed to
exception:
keyword argu…
…ment. Fixes #66.
- Loading branch information
Showing
2 changed files
with
47 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# frozen_string_literal: true | ||
|
||
# Released under the MIT License. | ||
# Copyright, 2021-2024, by Samuel Williams. | ||
|
||
require "console/logger" | ||
require "console/capture" | ||
|
||
require "console/output/failure" | ||
|
||
describe Console::Output::Failure do | ||
let(:output) {Console::Capture.new} | ||
let(:logger) {subject.new(output)} | ||
let(:error) {StandardError.new("Something went wrong")} | ||
|
||
it "logs exception messages" do | ||
logger.call(self, error) | ||
|
||
expect(output.last).to have_keys( | ||
event: have_keys( | ||
message: be == "Something went wrong" | ||
) | ||
) | ||
end | ||
|
||
it "logs exception keyword argument" do | ||
logger.call(self, exception: error) | ||
|
||
expect(output.last).to have_keys( | ||
event: have_keys( | ||
message: be == "Something went wrong" | ||
) | ||
) | ||
end | ||
|
||
it "logs non-exception exception keyword argument" do | ||
logger.call(self, exception: "Something went wrong") | ||
|
||
expect(output.last).to have_keys( | ||
exception: be == "Something went wrong" | ||
) | ||
end | ||
end |