Commit 12bcb3d
Fix flakey example in Project::CreateRemix spec
I've reproduced this example failure locally as follows:
bundle exec rspec --seed 58786 spec/concepts/project/create_remix_spec.rb:125
The problem was with the `component` factory using `Faker::Lorem.word`
to generate `Component#name` [1] and then the example relying on the
order of components which is partly based on `Component#name` [2]. And
thus depending on the value of the generated name,
`remixed_project.components.first` in the example didn't always refer to
the component that the author intended and the assertion would fail,
e.g. with the seed value of 58786, the original component had the name
"ad" which comes before the new component name of "added_component"
alphabetically.
While I have some reservations about the use of Faker in spec setup, the
simplest way to fix this is to find the new component by name before
asserting against its attribute values.
[1]: https://github.com/RaspberryPiFoundation/editor-api/blob/f397e870f2a33cce1f53b9104c52314f5233572c/spec/factories/component.rb#L5
[2]: https://github.com/RaspberryPiFoundation/editor-api/blob/f397e870f2a33cce1f53b9104c52314f5233572c/app/models/project.rb#L141 parent 206b1c4 commit 12bcb3d
1 file changed
+2
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
127 | | - | |
| 127 | + | |
| 128 | + | |
128 | 129 | | |
129 | 130 | | |
130 | 131 | | |
| |||
0 commit comments