38 lines
1.2 KiB
Ruby
38 lines
1.2 KiB
Ruby
require File.expand_path(File.dirname(__FILE__) + "/test_helper")
|
|
|
|
class JobTest < Test::Unit::TestCase
|
|
|
|
context "A Job" do
|
|
should "output the :task" do
|
|
job = new_job(:template => ":task", :task => 'abc123')
|
|
assert_equal %q(abc123), job.output
|
|
end
|
|
|
|
should "output the :task if it's in single quotes" do
|
|
job = new_job(:template => "':task'", :task => 'abc123')
|
|
assert_equal %q('abc123'), job.output
|
|
end
|
|
|
|
should "output the :task if it's in double quotes" do
|
|
job = new_job(:template => '":task"', :task => 'abc123')
|
|
assert_equal %q("abc123"), job.output
|
|
end
|
|
|
|
should "output escaped single quotes in :task when it's wrapped in them" do
|
|
job = new_job(:template => "outside ':task' outside", :task => "'inside'")
|
|
assert_equal %q(outside ''\''inside'\''' outside), job.output
|
|
end
|
|
|
|
should "output escaped double quotes in :task when it's wrapped in them" do
|
|
job = new_job(:template => 'outside ":task" outside', :task => '"inside"')
|
|
assert_equal %q(outside "\"inside"\" outside), job.output
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
def new_job(options)
|
|
Whenever::Job.new(options)
|
|
end
|
|
|
|
end |