Setting nil or blank environment variables now properly formats output

as ENVVAR="" instead of ENVVAR=.
This commit is contained in:
teejayvanslyke 2010-12-07 10:12:08 -08:00
parent ca10a69e83
commit fe022bb1c6
2 changed files with 12 additions and 2 deletions

View File

@ -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"

View File

@ -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
end