dry-rb / dry-container

A simple, configurable object container implemented in Ruby
https://dry-rb.org/gems/dry-container
MIT License
335 stars 41 forks source link

Make `DidYouMean` integration optional #86

Closed jbourassa closed 2 years ago

jbourassa commented 2 years ago

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 `<class:Container>'

With this commit, the gem loads even though some tests fail.


We run some of our Ruby apps with --disable-did_you_mean for performance reasons, hence the change.

I didn't write any tests for this. The only test I could think of would be something like shelling out to load a new Ruby interpreter without DidYouMean and validating that it doesn't fail:

ruby --disable-did_you_mean -r "dry-container" -e ""

I didn't see a lot of value in such test, but open to feedback or alternative.

cllns commented 2 years ago

Ah, sorry about that. I wrote the PR that added this feature and I failed to consider DidYouMean not being available for this reason.

solnic commented 2 years ago

Thanks for the PR. I just released 0.10.1 with your fix.

jbourassa commented 2 years ago

Thanks a ton @solnic 🙇.