Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

* gracefully handling gems that do not load

  • Loading branch information...
commit dd81b034e92ccbcf2082b7bbda2a5cbc472d27cc 1 parent a31f907
Luke Petre lpetre authored
4 Rakefile
@@ -18,7 +18,7 @@ Jeweler::Tasks.new do |s|
18 18 s.rdoc_options = ["--main", "README.textile", "--inline-source", "--line-numbers"]
19 19 s.extra_rdoc_files = ["README.textile"]
20 20
21   - s.test_files = Dir['spec/**/*']
  21 + s.test_files = Dir['spec/*_spec.rb']
22 22
23 23 s.add_dependency "daemons"
24 24 s.add_development_dependency "rspec"
@@ -38,7 +38,7 @@ task :default => :spec
38 38 desc 'Run the specs'
39 39 Spec::Rake::SpecTask.new(:spec) do |t|
40 40 t.libs << 'lib'
41   - t.pattern = 'spec/**/*_spec.rb'
  41 + t.pattern = 'spec/*_spec.rb'
42 42 t.verbose = true
43 43 end
44 44 task :spec => :check_dependencies
13 spec/backend/active_record_job_spec.rb
@@ -2,13 +2,13 @@
2 2 require 'backend/shared_backend_spec'
3 3 require 'delayed/backend/active_record'
4 4
5   -describe Delayed::Job do
  5 +describe Delayed::Backend::ActiveRecord::Job do
6 6 before(:all) do
7   - @backend = Delayed::Job
  7 + @backend = Delayed::Backend::ActiveRecord::Job
8 8 end
9 9
10 10 before(:each) do
11   - Delayed::Job.delete_all
  11 + Delayed::Backend::ActiveRecord::Job.delete_all
12 12 SimpleJob.runs = 0
13 13 end
14 14
@@ -27,14 +27,13 @@
27 27 it "should return UTC time if that is the AR default" do
28 28 Time.zone = nil
29 29 ActiveRecord::Base.default_timezone = :utc
30   - Delayed::Job.db_time_now.zone.should == 'UTC'
  30 + Delayed::Backend::ActiveRecord::Job.db_time_now.zone.should == 'UTC'
31 31 end
32 32
33 33 it "should return local time if that is the AR default" do
34 34 Time.zone = 'Central Time (US & Canada)'
35 35 ActiveRecord::Base.default_timezone = :local
36   - %w(CST CDT).should include(Delayed::Job.db_time_now.zone)
  36 + %w(CST CDT).should include(Delayed::Backend::ActiveRecord::Job.db_time_now.zone)
37 37 end
38   - end
39   -
  38 + end
40 39 end
0  spec/backend/datamapper_job_spec.rb → spec/backend/data_mapper_job_spec.rb
File renamed without changes
2  spec/setup/data_mapper.rb
@@ -3,4 +3,4 @@
3 3
4 4 DataMapper.logger = Delayed::Worker.logger
5 5 DataMapper.setup(:default, "sqlite3::memory:")
6   -DataMapper.auto_migrate!
  6 +DataMapper.auto_migrate!
2  spec/setup/mongo_mapper.rb
@@ -9,7 +9,7 @@ class Story
9 9 def tell; text; end
10 10 def whatever(n, _); tell*n; end
11 11 def self.count; end
12   -
  12 +
13 13 handle_asynchronously :whatever
14 14 end
15 15 end
18 spec/spec_helper.rb
@@ -6,16 +6,20 @@
6 6
7 7 require 'delayed_job'
8 8 require 'sample_jobs'
9   -require 'database_cleaner'
10 9
11 10 Delayed::Worker.logger = Logger.new('/tmp/dj.log')
12 11
13   -BACKENDS = [:active_record, :mongo_mapper, :data_mapper]
14   -
15   -BACKENDS.each do |backend|
16   - require "setup/#{backend}"
  12 +# determine the available backends
  13 +BACKENDS = []
  14 +Dir.glob("#{File.dirname(__FILE__)}/setup/*.rb") do |backend|
  15 + begin
  16 + backend = File.basename(backend, '.rb')
  17 + require "setup/#{backend}"
  18 + require "backend/#{backend}_job_spec"
  19 + BACKENDS << backend.to_sym
  20 + rescue LoadError
  21 + puts "Unable to load #{backend} backend! #{$!}"
  22 + end
17 23 end
18 24
19 25 Delayed::Worker.backend = BACKENDS.first
20   -DatabaseCleaner.orm = BACKENDS.first.to_s
21   -DatabaseCleaner.strategy = :truncation

0 comments on commit dd81b03

Please sign in to comment.
Something went wrong with that request. Please try again.