From 301675577c26b330ec74c507bec3b590e5e7beef Mon Sep 17 00:00:00 2001 From: Patrik Wenger Date: Thu, 18 Jul 2024 13:08:23 +0200 Subject: [PATCH] Event::Failure: add #exception --- lib/console/event/failure.rb | 4 +++- test/console/event/failure.rb | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/console/event/failure.rb b/lib/console/event/failure.rb index eb3d80e..f23505b 100644 --- a/lib/console/event/failure.rb +++ b/lib/console/event/failure.rb @@ -27,7 +27,9 @@ def self.for(exception) def self.log(subject, exception, **options) Console.error(subject, **self.for(exception).to_hash, **options) end - + + attr_reader :exception + def initialize(exception, root = Dir.getwd) @exception = exception @root = root diff --git a/test/console/event/failure.rb b/test/console/event/failure.rb index 666a07b..814fa00 100644 --- a/test/console/event/failure.rb +++ b/test/console/event/failure.rb @@ -53,5 +53,11 @@ def detailed_message(...) ) ) end + + it "can get #exception" do + failure = Console::Event::Failure.for(error) + + expect(failure.exception).to be == error + end end end