Warning to anyone trying to verify that constants are defined: If your code refers to an undefined constant when defining a class, then your specifications will break before they get into your test.
It can make you believe that
expect { FOO }.to_not raise_error
it is not possible to catch NameError because you will get a large stack trace, and not a good "expected so as not to raise an error, but raise the NameError value".
Amid the huge stack trace, it can be hard to notice that your test is actually crashing on line 1: requre "spec / spec_helper" because your whole application does not load before it reaches your actual test.
This can happen if you have dynamically defined constants, for example, using ActiveHash :: Enum, and then use them in the definition of another constant. Do not bother checking that they exist, each specification in your application will fail if one of them is not defined.
Avram
source share