module BobTheHelper module Environment # Set environment variable for code block # # @param [Hash] variables # the variables which should be set for that environment # # @yield # the block which should be run which the change environment def isolated_environment(variables, &block) #backup old_env = ENV.to_hash #change env ENV.update variables block_result = block.call #cleanup ENV.clear #install backuped information ENV.update old_env block_result end end end