Permalink
Browse files

Use database_cleaner in specs

  • Loading branch information...
1 parent 452a040 commit 7605ed00f97a6214d7717c5e4a87b9779db78f64 @bkeepers bkeepers committed Mar 26, 2010
Showing with 9 additions and 4 deletions.
  1. +1 −0 Rakefile
  2. +0 −2 spec/backend/active_record_job_spec.rb
  3. +2 −0 spec/backend/shared_backend_spec.rb
  4. +4 −1 spec/spec_helper.rb
  5. +2 −1 spec/worker_spec.rb
View
@@ -28,6 +28,7 @@ Jeweler::Tasks.new do |s|
s.add_development_dependency "dm-observer"
s.add_development_dependency "dm-aggregates"
s.add_development_dependency "do_sqlite3"
+ s.add_development_dependency "database_cleaner"
end
require 'spec/rake/spectask'
@@ -8,8 +8,6 @@
end
before(:each) do
- Delayed::Worker.max_priority = nil
- Delayed::Worker.min_priority = nil
Delayed::Job.delete_all
SimpleJob.runs = 0
end
@@ -4,6 +4,8 @@ def create_job(opts = {})
end
before do
+ Delayed::Worker.max_priority = nil
+ Delayed::Worker.min_priority = nil
SimpleJob.runs = 0
end
View
@@ -6,13 +6,16 @@
require 'delayed_job'
require 'sample_jobs'
+require 'database_cleaner'
Delayed::Worker.logger = Logger.new('/tmp/dj.log')
-BACKENDS = [:active_record, :mongo_mapper]
+BACKENDS = [:active_record, :mongo_mapper, :data_mapper]
BACKENDS.each do |backend|
require "setup/#{backend}"
end
Delayed::Worker.backend = BACKENDS.first
+DatabaseCleaner.orm = BACKENDS.first.to_s
+DatabaseCleaner.strategy = :truncation
View
@@ -23,7 +23,8 @@ def job_create(opts = {})
describe "with the #{backend} backend" do
before do
Delayed::Worker.backend = backend
- Delayed::Job.delete_all
+ DatabaseCleaner.orm = backend.to_s
+ DatabaseCleaner.clean
@worker = Delayed::Worker.new(:max_priority => nil, :min_priority => nil, :quiet => true)

0 comments on commit 7605ed0

Please sign in to comment.