Skip to content

Add support to temporarily remove constants

gitlab-qa-bot requested to merge github/fork/alindeman/hide_const into master

Created by: alindeman

This would be the analog to stub_const, but rather than setting a constant for the duration of an example, it would remove a constant for the duration of an example.

The main use I see for this is when you're testing code that does something conditionally based on whether or not some other library is loaded (and checks the presence of constants to detect it)--being able to remove a constant for an example would make it easy to specify how the code behaves when the library is not loaded.

I have no idea what to name this method, though. It's kinda the opposite of stub_const but unstub_const doesn't give the right sense at all. remove_const sounds OK but that'll class with a core ruby method.

Any ideas?

Also, do others think this would be a useful feature?

Merge request reports