From 1f504f5f9b6fe0637789d98ceecd2cd7e7586bea Mon Sep 17 00:00:00 2001 From: Johan Holmberg Date: Fri, 14 Aug 2009 14:05:06 +0200 Subject: [PATCH] Add "chdir" method. Can be used to avoid ruby warning "conflicting chdir during another chdir block". --- lib/cmdtest/testcase.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/cmdtest/testcase.rb b/lib/cmdtest/testcase.rb index 97e0f9a..c22134d 100644 --- a/lib/cmdtest/testcase.rb +++ b/lib/cmdtest/testcase.rb @@ -115,6 +115,20 @@ module Cmdtest FileUtils.touch(filename) end + #------------------------------ + # A "chdir" to be used in tests, to avoid the Ruby warning: + # + # warning: conflicting chdir during another chdir block + # + + def chdir(dir, &block) + if block_given? + Util.chdir(dir, &block) + else + Dir.chdir(dir) + end + end + #------------------------------ # Don't count the specified file when calculating the "side effects" # of a command.