David Chelimsky

random thoughtlessness

Lessons in Spec'ing

Lesson: system calls in specs do stuff on your system. Be careful.

I was trying different things to understand why a spec was failing and, at one point, put a pending statement in a spec that generates a file and then deletes it. The statement that deletes the file is in an after(:each) block (which is guaranteed to run) and looks like this:

<code>system(%Q|rm "#{dir}/#{filename}"|)</code>

Imagine my horror when I saw this in the output:

rm: /: is a directory