From 7a61abdac2749e914bf5b20dac02525e48f5d359 Mon Sep 17 00:00:00 2001 From: Jimmy Bourassa Date: Thu, 28 Jul 2022 17:55:21 -0400 Subject: [PATCH] Make `DidYouMean` integration optional The gem won't load when DidYouMean is disabled with --disable-did_you_mean: ``` RUBYOPT='--disable-did_you_mean' rake [...] NameError: uninitialized constant Dry::Container::DidYouMean # ./lib/dry/container/error.rb:9:in `' ``` With this commit, the gem loads even though some tests fail. --- lib/dry/container/error.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/dry/container/error.rb b/lib/dry/container/error.rb index 5311e16..80f6dd8 100644 --- a/lib/dry/container/error.rb +++ b/lib/dry/container/error.rb @@ -6,7 +6,9 @@ class Container Error = Class.new(StandardError) KeyError = Class.new(::KeyError) - DidYouMean.correct_error(KeyError, DidYouMean::KeyErrorChecker) + if defined?(DidYouMean::KeyErrorChecker) + DidYouMean.correct_error(KeyError, DidYouMean::KeyErrorChecker) + end deprecate_constant(:Error) end