Forum: Ruby Cucumber - Aruba tests with FileUtils vs Dir

Posted by Steve Riley (slayd)
on 2013-02-12 22:13
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.
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.