Closed timrogers closed 6 years ago
Thanks for this @timrogers.
I like this change, but am a little worried about the implications of this. It seems a bit dangerous that we would delete files in folders that we have no idea are related to the gem itself. Would it not be better to allow a custom path to be provided, or perhaps a flag to enable directory recursive wildcard pruning?
Hmm, you're right. I'm making the assumption here that you only store screenshots within the directory structure, but it's correct that you might store other things too. I'll look at making recursive pruning optional.
Are the failures anything to do with me by the way? It looks like the message raised by Capybara has changed to mention a "visible link or button".
I'm not going to have time to work further on this realistically, and I think there are challenges to doing this well, so I'm going to close the PR.
The pruning functionality included in this gem makes it easy to clean up old screenshots.
By configuring
Capybara::Screenshot.register_filename_prefix_formatter
, you can set your own path for screenshots to be captured at, which may include a more complicated directory structure (for example, for one of my projects, we want to organise screenshots based on the spec file that generated them, with the filename including the line number of the example).At the moment,
Pruner
only cleans up*.{html,png}
, meaning that more complex directory structures are not pruned. This switches to using the glob**/*.{html,png}
, delving into subdirectories, and then deleting any empty subdirectories at the end.