During doing unit tests in Rails a few temp files are created (associated with model). When test is done I want to remove these files, so I have to find a way to do this no matter the test passes or not.
So, what are you suggestions?
During doing unit tests in Rails a few temp files are created (associated with
Share
Why not put the file creation in a setup and the destruction in a teardown function? Then the creation will run beforehand – no matter what – and the destruction will run afterwards – again, no matter what. If you want setup and teardown of these files only for certain conditions, there’s a nice writeup on it here: http://technicalpickles.com/posts/rails-special-sauce-test-unit-setup-and-teardown/