-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make RandomExample take an optional 'seed' parameter
The previous approach to deterministic behaviour was to rely on 'srand' being set upstream, so that it is up to the app to define a seed if they wish to have consistent results. However, if the srand is not set explicitly by the developer, and if the test framework (such as RSpec) does not set the seed to a random value, then the 'random example' will be the same example every time, by default. This could be surprising. We decided it is better to make the developer explicitly opt in to seed behaviour, than it is to make them set a random seed in order to get a 'true' random on every test run. This commit is part 1: defining the 'seed' parameter. Part 2 comes in the next commit, where we'll swap out the call to 'srand' and use an instance of Random, to prevent changing the global state of things. Full discussion: https://github.com/alphagov/govuk_schemas/pull/56/files\#r458182188
- Loading branch information
1 parent
241b921
commit 9ddca1d
Showing
3 changed files
with
11 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters