Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow smart answer flows to be defined at runtime not load time
This makes it possible to define smart answer flows as a subclass of `SmartAnswer::Flow` such that we can obtain test coverage data for the flow logic. This data was not previously available [1], because the flow files were being read and eval'ed (at load time) rather than simply required. The latter is necessary [2] for `SimpleCov` to record coverage data for the file. By extracting the existing DSL code into a `define` method on a subclass of `SmartAnswer::Flow`, we can safely require the file separately from instantiating the flow. This feels like a better state of affairs in general, but it specifically addresses the test coverage problem above. We'd want to have this coverage data available so we can have confidence that we're not breaking anything as we continue to refactor the app. No flows have been converted in this commit, it just makes it possible to convert them. The plan is to convert each flow one at a time in subsequent commits. I've chosen to suffix the subclass name with the word `Flow`, because I hit autoloading problems when running **all** the tests, because there are a bunch of classes in the `SmartAnswer::Calculators` namespace with the same name as flows. [1]: https://ci-new.alphagov.co.uk/job/govuk_smart_answers/2396/rcov/ [2]: simplecov-ruby/simplecov#38
- Loading branch information