During #635 review we detected some flakyness while some attempts of fixing Travis. After some investigation I was able to identify an issue with the TempFile usage used in our to_fixture_file function to create temporary dynamic content fixture.
From the ruby docs:
When a Tempfile object is garbage collected, or when the Ruby interpreter exits, its associated temporary file is automatically deleted.
In some randomized seeds a temp file was being removed and no content was being uploaded, since the file didn't exist, and the file content wasn't being displayed on the screen as expected.
Since there's no way of controlling when GC is going to remove the temp files, the only way is trying to keep the reference on hold to be usable. The solution for this was to simply return the TempFile instance from to_file_fixture instead of the path or base name.
During #635 review we detected some flakyness while some attempts of fixing Travis. After some investigation I was able to identify an issue with the
TempFile
usage used in ourto_fixture_file
function to create temporary dynamic content fixture.From the ruby docs:
In some randomized seeds a temp file was being removed and no content was being uploaded, since the file didn't exist, and the file content wasn't being displayed on the screen as expected.
Since there's no way of controlling when GC is going to remove the temp files, the only way is trying to keep the reference on hold to be usable. The solution for this was to simply return the TempFile instance from
to_file_fixture
instead of the path or base name.A practical example can be found at https://www.hilman.io/blog/2016/01/tempfile/
Signed-off-by: Vítor Avelino contact@vitoravelino.me