trouble setting up cucumber to test without actually changing the file system

287 Views Asked by At

I have been struggling for a while with this problem. I'm trying to test a ruby CLI that uses a lot of fileutils operations like making directories and copying files, etc. But when I'm writing tests, I need some way to test the functionality without touching and changing the actual filesystem. I am trying to use the fakefs gem but I am running into a error right away

When I successfully run `dotfiles init`                           # aruba-0.5.3/lib/aruba/cucumber.rb:71
      No such file or directory - No such file or directory - /tmp/aruba-out20130817-15800-ke8nou (Errno::ENOENT)
      /Users/Brian/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/tempfile.rb:146:in `open'
      /Users/Brian/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/tempfile.rb:146:in `block in initialize'
      /Users/Brian/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/tmpdir.rb:142:in `create'
      /Users/Brian/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/tempfile.rb:136:in `initialize'
      features/dotfiles_repository.feature:8:in `When I successfully run `dotfiles init`'

So its not finding /tmp/aruba which is where cucumber aruba does all of its file operations according to the readme. The tests run fine without fakefs, so I'm assuming its something with the setup.

Here is my features/support/env.rb file

require 'aruba/cucumber'
require 'fakefs/safe'

Before do
  FakeFS.activate!
end

After do
  FakeFS::FileSystem.clear
  FakeFS.deactivate!
end

Does anyone have any idea what I may be doing wrong? Any help is appreciated. Even if its an idea that doesn't use fakefs, I would like to hear it. Thanks

0

There are 0 best solutions below