Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Require all backends for running the tests (sorry, if you're gonna co…

…ntribute, then you gotta make sure all the tests pass)
  • Loading branch information...
commit 3a7c29eb44e42790bf76fdeaf6b458322bd9a20a 1 parent b5cabbd
@bkeepers bkeepers authored
View
3  Rakefile
@@ -23,6 +23,7 @@ Jeweler::Tasks.new do |s|
s.add_dependency "daemons"
s.add_development_dependency "rspec"
s.add_development_dependency "sqlite3-ruby"
+ s.add_development_dependency "mongo_mapper"
end
require 'spec/rake/spectask'
@@ -32,7 +33,7 @@ task :default => :spec
desc 'Run the specs'
Spec::Rake::SpecTask.new(:spec) do |t|
t.libs << 'lib'
- t.pattern = 'spec/*_spec.rb'
+ t.pattern = 'spec/**/*_spec.rb'
t.verbose = true
end
task :spec => :check_dependencies
View
1  spec/backend/active_record_job_spec.rb
@@ -1,4 +1,5 @@
require 'spec_helper'
+require 'backend/shared_backend_spec'
require 'delayed/backend/active_record'
describe Delayed::Job do
View
2  spec/backend/mongo_mapper_job_spec.rb
@@ -1,5 +1,5 @@
require 'spec_helper'
-
+require 'backend/shared_backend_spec'
require 'delayed/backend/mongo_mapper'
describe Delayed::Backend::MongoMapper::Job do
View
2  spec/setup/active_record.rb
@@ -1,7 +1,7 @@
require 'active_record'
ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => ':memory:')
-ActiveRecord::Base.logger = DELAYED_JOB_LOGGER
+ActiveRecord::Base.logger = Delayed::Worker.logger
ActiveRecord::Migration.verbose = false
ActiveRecord::Schema.define do
View
4 spec/setup/mongo_mapper.rb
@@ -1,4 +1,6 @@
-MongoMapper.connection = Mongo::Connection.new nil, nil, :logger => DELAYED_JOB_LOGGER
+require 'mongo_mapper'
+
+MongoMapper.connection = Mongo::Connection.new nil, nil, :logger => Delayed::Worker.logger
MongoMapper.database = 'delayed_job'
unless defined?(Story)
View
27 spec/spec_helper.rb
@@ -4,32 +4,15 @@
require 'spec'
require 'logger'
-backends_available = []
-%w(active_record mongo_mapper).each do |backend|
- begin
- require backend
- backends_available << backend
- rescue LoadError => e
- $stderr.puts "The backend '#{backend}' is not available. Skipping tests"
- end
-end
-
-if backends_available.empty?
- raise LoadError, "Cannot run delayed_job specs. No backends available"
-end
-
require 'delayed_job'
require 'sample_jobs'
-require 'backend/shared_backend_spec'
-
-DELAYED_JOB_LOGGER = Logger.new('/tmp/dj.log')
-Delayed::Worker.logger = DELAYED_JOB_LOGGER
-DEFAULT_BACKEND = backends_available.first.to_sym
+Delayed::Worker.logger = Logger.new('/tmp/dj.log')
-Delayed::Worker.backend = DEFAULT_BACKEND
+BACKENDS = [:active_record, :mongo_mapper]
-backends_available.each do |backend|
+BACKENDS.each do |backend|
require "setup/#{backend}"
- require "backend/#{backend}_job_spec"
end
+
+Delayed::Worker.backend = BACKENDS.first
View
2  spec/worker_spec.rb
@@ -19,7 +19,7 @@ def job_create(opts = {})
end
end
- [:active_record, :mongo_mapper].each do |backend|
+ BACKENDS.each do |backend|
describe "with the #{backend} backend" do
before do
Delayed::Worker.backend = backend
Please sign in to comment.
Something went wrong with that request. Please try again.