You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 30, 2024. It is now read-only.
Set alternative RSpec invocations as callables in OptionParser
RSpec can be invoked with a number of CLI flags that result in substantially
different code paths. As well as the default runner, there is:
* `--init` - initializes the project directory and exits
* `--help` - prints CLI usage and exits
* `--version` - prints the version and exits
* `--drb` - runs examples via a DRb connection
* `--bisect` - starts a bisection process
Previously some of these paths were invoked directly in the OptionParser
(--init, --help and --version), while others were invoked by the main
Runner.run call. This necessitated a lot of complexity in Runner.run, and a
reasonable amount of stubbing of exit calls (which can be error-prone, and
lead to a prematurely-terminated test run).
This commit refactors the different invocations into callables, which the
OptionParser sets as the `:runner` option. If an alternative invocation is
found in Runner.run, it is used, falling back to the default of instantiating
a Runner and starting it.
The invocation callables do not handle exiting themselves, but are required to
return an exit code instead. They must all accept the following arguments:
@param options [RSpec::Core::ConfigurationOptions]
@param err [IO]
@param out [IO]
At the moment the invocations are tested via the OptionParser specs - in
future work we intend to extract these to their own module and test them
independently.
0 commit comments