Permalink
Browse files

Default the timing options if they are not specified

  • Loading branch information...
1 parent a88babd commit bc689723a21b364015d1c112cb744dd437b8750d @halorgium halorgium committed Apr 8, 2008
Showing with 6 additions and 2 deletions.
  1. +1 −1 lib/crondle/builder.rb
  2. +1 −1 lib/crondle/job.rb
  3. +4 −0 spec/crondle/job_spec.rb
@@ -5,7 +5,7 @@ def desc(desc)
@next_desc = desc
end
- def job(cmd, options)
+ def job(cmd, options = {})
jobs << Job.new(next_desc, cmd, options)
end
View
@@ -12,7 +12,7 @@ class InvalidTimingParamError < StandardError; end
attr_accessor :description,
:cmd
- def initialize(description, cmd, timing_options)
+ def initialize(description, cmd, timing_options = {})
self.description = description
self.cmd = cmd
set_timing_options(timing_options)
@@ -52,6 +52,10 @@ module Crondle
Job.new("desc", "ls", {}).to_s.count("*").should equal(5)
end
+ it "should allow only 2 arguments" do
+ Job.new("desc", "ls").to_s.count("*").should equal(5)
+ end
+
it "should work if day_of_week is a symbol OR a string" do
lambda {Job.new("desc", "ls", :day_of_week => :monday)}.should_not raise_error(Job::InvalidTimingParamError)
lambda {Job.new("desc", "ls", :day_of_week => 'monday')}.should_not raise_error(Job::InvalidTimingParamError)

0 comments on commit bc68972

Please sign in to comment.