23 Oct 2012, 18:59
Generic-user-small

Warren Pollans (1 post)

From page 126 of pdf - I don’t see how this does what the last line below states - in Before block, fake_home is not created, it’s deleted. Help please

tolerate_gracefully/todo/features/support/env.rb

Before do @real_home = ENV[‘HOME’] fake_home = File.join(‘/tmp’,’fake_home’) FileUtils.rm_rf fake_home, :secure => true ENV[‘HOME’] = fake_home end After do ENV[‘HOME’] = @real_home end

As you can see, we create a fresh, empty directory and point ENV[‘HOME’] to it.

24 Oct 2012, 22:31
Dmfcb_pragsmall

David Copeland (98 posts)

Yes, this seems wrong. I think that the way GLI uses the config file that we configure, it will just create the missing directories (the tests do all pass).

I think what it should really be is:

Before do
  @real_home = ENV[‘HOME’]
  fake_home = File.join(’/tmp’,’fake_home’)
  FileUtils.rm_rf fake_home, :secure => true
  ENV[‘HOME’] = fake_home
  FileUtils.mkdir fake_home # <=====
end
After do
  ENV[‘HOME’] = @real_home
end

This would allow the concept to work for apps that don’t create the directory if it’s missing (which is probably most of them).

Nice catch

  You must be logged in to comment