Permalink
Browse files

fix: compatibility with ruby 2.3.0 + activesupport

  • Loading branch information...
1 parent 9f0f22a commit 254d30efd097bc940d151aae2480827c5eb93b25 Vincent Boisard committed with benlangfeld Jan 7, 2016
Showing with 27 additions and 2 deletions.
  1. +1 −0 .gitignore
  2. +9 −2 .travis.yml
  3. +5 −0 gemfiles/activesupport4.1.gemfile
  4. +5 −0 gemfiles/activesupport4.2.gemfile
  5. +1 −0 lib/whenever/cron.rb
  6. +6 −0 test/unit/cron_test.rb
View
@@ -3,3 +3,4 @@ pkg
doc
.*.sw[a-z]
Gemfile.lock
+gemfiles/*.lock
View
@@ -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
@@ -0,0 +1,5 @@
+source "https://rubygems.org"
+
+gem "activesupport", "~> 4.1.0"
+
+gemspec path: "../"
@@ -0,0 +1,5 @@
+source "https://rubygems.org"
+
+gem "activesupport", "~> 4.2.0"
+
+gemspec path: "../"
@@ -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
@@ -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

0 comments on commit 254d30e

Please sign in to comment.