Cleaned up requirements, paths, test structure

This commit is contained in:
Javan Makhmali 2010-09-06 13:18:39 -04:00
parent 1472fecc4b
commit 27827c8e17
15 changed files with 29 additions and 51 deletions

View File

@ -1,7 +1,7 @@
require 'rubygems' require 'rubygems'
require 'rake' require 'rake'
require 'lib/whenever/version.rb' require File.expand_path(File.dirname(__FILE__) + "/lib/whenever/version")
begin begin
require 'jeweler' require 'jeweler'
@ -13,7 +13,10 @@ begin
gemspec.email = "javan@javan.us" gemspec.email = "javan@javan.us"
gemspec.homepage = "http://github.com/javan/whenever" gemspec.homepage = "http://github.com/javan/whenever"
gemspec.authors = ["Javan Makhmali"] gemspec.authors = ["Javan Makhmali"]
gemspec.add_dependency("chronic", '>= 0.2.3') gemspec.add_dependency 'chronic', '>= 0.2.3'
gemspec.add_dependency 'activesupport', '>= 2.3.4'
gemspec.add_development_dependency 'shoulda', '>= 2.1.1'
gemspec.add_development_dependency 'mocha', '>= 0.9.5'
end end
Jeweler::GemcutterTasks.new Jeweler::GemcutterTasks.new
rescue LoadError rescue LoadError
@ -22,10 +25,10 @@ end
require 'rake/testtask' require 'rake/testtask'
Rake::TestTask.new(:test) do |test| Rake::TestTask.new(:test) do |test|
test.libs << 'lib' << 'test' test.libs << 'lib' << 'test'
test.pattern = 'test/*.rb' test.pattern = 'test/{functional,unit}/**/*_test.rb'
test.verbose = true test.verbose = true
end end
task :test => :check_dependencies task :test => :check_dependencies

View File

@ -1,20 +1,10 @@
require 'chronic' require 'chronic'
require 'active_support/all'
# It was previously defined as a dependency of this gem, but that became
# problematic. See: http://github.com/javan/whenever/issues#issue/1
begin
require 'active_support/all'
rescue LoadError
warn 'To use Whenever you need the active_support gem:'
warn '$ gem install activesupport'
exit(1)
end
# Whenever files
require 'whenever/base' require 'whenever/base'
require 'whenever/job_list' require 'whenever/job_list'
require 'whenever/job' require 'whenever/job'
require 'whenever/outputs/cron' require 'whenever/cron'
require 'whenever/outputs/cron/output_redirection' require 'whenever/output_redirection'
require 'whenever/command_line' require 'whenever/command_line'
require 'whenever/version' require 'whenever/version'

View File

@ -1,6 +1,5 @@
module Whenever module Whenever
module Output module Output
class Cron class Cron
attr_accessor :time, :task attr_accessor :time, :task
@ -43,7 +42,7 @@ module Whenever
end end
def output_redirection def output_redirection
OutputRedirection.new(@output_redirection).to_s unless @output_redirection == :not_set Whenever::Output::Cron::OutputRedirection.new(@output_redirection).to_s unless @output_redirection == :not_set
end end
protected protected
@ -60,7 +59,7 @@ module Whenever
end end
if shortcut if shortcut
if @at.is_a?(Time) || (@at.is_a?(Numeric) && @at>0) if @at.is_a?(Time) || (@at.is_a?(Numeric) && @at > 0)
raise ArgumentError, "You cannot specify an ':at' when using the shortcuts for times." raise ArgumentError, "You cannot specify an ':at' when using the shortcuts for times."
else else
return shortcut return shortcut
@ -134,6 +133,5 @@ module Whenever
end end
end end
end end
end end

View File

@ -1,4 +1,4 @@
require File.expand_path(File.dirname(__FILE__) + "/test_helper") require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
class CommandLineTest < Test::Unit::TestCase class CommandLineTest < Test::Unit::TestCase

View File

@ -1,4 +1,4 @@
require File.expand_path(File.dirname(__FILE__) + "/test_helper") require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
class OutputAtTest < Test::Unit::TestCase class OutputAtTest < Test::Unit::TestCase

View File

@ -1,4 +1,4 @@
require File.expand_path(File.dirname(__FILE__) + "/test_helper") require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
class OutputCommandTest < Test::Unit::TestCase class OutputCommandTest < Test::Unit::TestCase

View File

@ -1,4 +1,4 @@
require File.expand_path(File.dirname(__FILE__) + "/test_helper") require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
class OutputDefinedJobTest < Test::Unit::TestCase class OutputDefinedJobTest < Test::Unit::TestCase

View File

@ -1,4 +1,4 @@
require File.expand_path(File.dirname(__FILE__) + "/test_helper") require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
class OutputEnvTest < Test::Unit::TestCase class OutputEnvTest < Test::Unit::TestCase

View File

@ -1,4 +1,4 @@
require File.expand_path(File.dirname(__FILE__) + "/test_helper") require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
class OutputRakeTest < Test::Unit::TestCase class OutputRakeTest < Test::Unit::TestCase

View File

@ -1,4 +1,4 @@
require File.expand_path(File.dirname(__FILE__) + "/test_helper") require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
class OutputRedirectionTest < Test::Unit::TestCase class OutputRedirectionTest < Test::Unit::TestCase

View File

@ -1,4 +1,4 @@
require File.expand_path(File.dirname(__FILE__) + "/test_helper") require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
class OutputRunnerTest < Test::Unit::TestCase class OutputRunnerTest < Test::Unit::TestCase

View File

@ -1,24 +1,11 @@
require 'rubygems' require 'rubygems'
require 'test/unit'
require File.expand_path(File.dirname(__FILE__) + "/../lib/whenever") # Want to test the files here, in lib, not in an installed version of the gem.
$:.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
begin require 'whenever'
require 'shoulda'
rescue LoadError
warn 'To test Whenever you need the shoulda gem:'
warn '$ sudo gem install thoughtbot-shoulda'
exit(1)
end
begin
require 'mocha'
rescue LoadError
warn 'To test Whenever you need the mocha gem:'
warn '$ sudo gem install mocha'
exit(1)
end
require 'shoulda'
require 'mocha'
module TestExtensions module TestExtensions

View File

@ -1,4 +1,4 @@
require File.expand_path(File.dirname(__FILE__) + "/test_helper") require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
class CronTest < Test::Unit::TestCase class CronTest < Test::Unit::TestCase

View File

@ -1,4 +1,4 @@
require File.expand_path(File.dirname(__FILE__) + "/test_helper") require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
class JobTest < Test::Unit::TestCase class JobTest < Test::Unit::TestCase