Skip to content

Commit

Permalink
fix: compatibility with ruby 2.3.0 + activesupport
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent Boisard authored and benlangfeld committed Jun 5, 2016
1 parent 9f0f22a commit 254d30e
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ pkg
doc
.*.sw[a-z]
Gemfile.lock
gemfiles/*.lock
11 changes: 9 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
language: ruby
script: bundle exec rake

before_install:
- gem install bundler

rvm:
- 1.9.3
- 2.0.0
- 2.1.0
- 2.2.0
- 2.3.0
- jruby
before_install:
- gem install bundler

gemfile:
- Gemfile
- gemfiles/activesupport4.1.gemfile
- gemfiles/activesupport4.2.gemfile
5 changes: 5 additions & 0 deletions gemfiles/activesupport4.1.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
source "https://rubygems.org"

gem "activesupport", "~> 4.1.0"

gemspec path: "../"
5 changes: 5 additions & 0 deletions gemfiles/activesupport4.2.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
source "https://rubygems.org"

gem "activesupport", "~> 4.2.0"

gemspec path: "../"
1 change: 1 addition & 0 deletions lib/whenever/cron.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def output
end

def time_in_cron_syntax
@time = @time.to_i if @time.is_a?(Numeric) # Compatibility with `1.day` format using ruby 2.3 and activesupport
case @time
when REGEX then @time # raw cron syntax given
when Symbol then parse_symbol
Expand Down
6 changes: 6 additions & 0 deletions test/unit/cron_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,12 @@ class CronParseShortcutsTest < Whenever::TestCase
end
end

class CronParseRubyTimeTest < Whenever::TestCase
should "process things like `1.day` correctly" do
assert_equal "0 0 * * *", parse_time(1.day)
end
end

class CronParseRawTest < Whenever::TestCase
should "raise if cron-syntax string is too long" do
assert_raises ArgumentError do
Expand Down

0 comments on commit 254d30e

Please sign in to comment.