I want to test that a program will trap Errno::EACCES.

I have a cucumber step that, in my starting working directory
  creates a subdirectory if it doesn't already exist, with mode 0111
  cd's to that subdirectory

Later I have a cucumber step that runs my program
  and tries to create a new directory (hopefully within this restricted
subdirectory)

If I use FileUtils.cd, the test passes when mkdir fails with
Errno::EACCES

If I use system("cd #{subdirectory}") the test fails when a new
directory
is created in the original, starting working directory and not this
special, restricted subdirectory.

If I use Dir.chdir("#{subdirectory}") the same thing happens as with the
ruby system
call.

Why does a directory change using FileUtils hold across the various
cucumber steps, but the other means to change directory do not?

I did verify in the first step that the program was in the subdirectory
for all three operations, at least for the duration of that step.

-- 
Posted via http://www.ruby-forum.com/.