Testing Environment Variable Processing in Whenever Cron Generation
This test suite validates environment variable handling in the Whenever gem’s cron job generation functionality. It ensures proper setting and formatting of environment variables when generating cron schedules, covering both standard and edge cases.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
javan/whenever
test/functional/output_env_test.rb
require 'test_helper'
class OutputEnvTest < Whenever::TestCase
setup do
@output = Whenever.cron \
<<-file
env :MYVAR, 'blah'
env 'MAILTO', "[email protected]"
env :BLANKVAR, ''
env :NILVAR, nil
file
end
should "output MYVAR environment variable" do
assert_match "MYVAR=blah", @output
end
should "output MAILTO environment variable" do
assert_match "[email protected]", @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