A Better File Wiper 📂
A tried-and-true debugging technique is to
tail the test log:
$ tail -f log/test.log
When the output gets noisy, we might 'wipe' the log by removing it, so that it only contains the output from a single action:
$ rm log/test.log && rspec spec/features/user_logs_in_spec.rb
A better way to do this is to overwrite the file, like so:
$ echo '' > log/test.log
This wipes the file without replacing it, which preserves its serial number. It's less destructive, and allows other processes interacting with the file to finish their work.
Here's an example of this principle in action, using
ls -i. Notice how the file's serial number changes when we replace the file, but not when we ovewrite it.
$ ls -i *.txt 27232432 foobar.txt $ rm foobar.txt $ touch foobar.txt $ ls -i *.txt 27232453 foobar.txt $ echo '' > foobar.txt $ ls -i *.txt 27232453 foobar.txt
h/t Brian DunnTweet