Trying my first (very small) project, and of course I want to spec test it.
It’s a cli command, so I’ve factored out the main logic into a class for easy testing. But I would rather use the simple way of doing
abort("missing argument") unless args.some_arg, as that one of the things I like about Ruby.
But how to handle this in a spec test? I’ve figured out that I can redefine
abort() in my test, and do an assertion, but got kinda stuck on where to stick the message for inspection as there seems to be no such thing as global variables (or top level instance/class variables). But I might be barking up the wrong tree here.
What would be the most elegant way to test a class that calls
abort() in some cases? Or do I have to translate it to an exception and catch that to do an abort in the main file wrapper?