small medium large xlarge

Generic-user-small
23 Oct 2012, 18:59
Warren Pollans (3 posts)

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.

Dmfcb_pragsmall
24 Oct 2012, 22:31
David Copeland (501 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