From fe022bb1c6214c626db320c4a7bf93c82c6ddc3c Mon Sep 17 00:00:00 2001 From: teejayvanslyke Date: Tue, 7 Dec 2010 10:12:08 -0800 Subject: [PATCH] Setting nil or blank environment variables now properly formats output as ENVVAR="" instead of ENVVAR=. --- lib/whenever/job_list.rb | 2 +- test/functional/output_env_test.rb | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/whenever/job_list.rb b/lib/whenever/job_list.rb index b04104d..444137a 100644 --- a/lib/whenever/job_list.rb +++ b/lib/whenever/job_list.rb @@ -88,7 +88,7 @@ module Whenever output = [] @env.each do |key, val| - output << "#{key}=#{val}\n" + output << "#{key}=#{val.blank? ? '""' : val}\n" end output << "\n" diff --git a/test/functional/output_env_test.rb b/test/functional/output_env_test.rb index 2dd3fa7..320a676 100644 --- a/test/functional/output_env_test.rb +++ b/test/functional/output_env_test.rb @@ -8,6 +8,8 @@ class OutputEnvTest < Test::Unit::TestCase <<-file env :MYVAR, 'blah' env 'MAILTO', "someone@example.com" + env :BLANKVAR, '' + env :NILVAR, nil file end @@ -18,6 +20,14 @@ class OutputEnvTest < Test::Unit::TestCase should "output MAILTO environment variable" do assert_match "MAILTO=someone@example.com", @output end + + should "output BLANKVAR environment variable" do + assert_match "BLANKVAR=\"\"", @output + end + + should "output NILVAR environment variable" do + assert_match "NILVAR=\"\"", @output + end end -end \ No newline at end of file +end