Skip to content

Commit

Permalink
feature: spec on missing superclass for on_failure_retry
Browse files Browse the repository at this point in the history
  • Loading branch information
isqad committed Mar 19, 2018
1 parent 5f51d7b commit eeacf88
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
34 changes: 27 additions & 7 deletions spec/resque/integration/unique_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,17 +147,37 @@ def self.execute(foo_var, params)
end
end

class JobOnlyUnique
include Resque::Integration

unique

def self.execute
raise 'Some exception in Job'
end
end

let(:worker) { Resque::Worker.new(:default) }
let(:job) { Resque::Job.new(:default, 'class' => 'JobUniqueWithRetry', 'args' => ['abcd', 1, {foo: 'bar'}]) }

before do
worker.working_on(job)

context 'when unique with retry' do
let(:job) { Resque::Job.new(:default, 'class' => 'JobUniqueWithRetry', 'args' => ['abcd', 1, {foo: 'bar'}]) }

before { worker.working_on(job) }

it do
expect { worker.unregister_worker }.not_to raise_error

expect(Resque::Failure.count).to eq 1
expect(Resque::Failure.all['exception']).to eq 'Resque::DirtyExit'
end
end

it do
expect { worker.unregister_worker }.not_to raise_error
context 'when only unique' do
let(:job) { Resque::Job.new(:default, 'class' => 'JobOnlyUnique', 'args' => ['abcd']) }

expect(Resque::Failure.count).to eq 1
expect(Resque::Failure.all['exception']).to eq 'Resque::DirtyExit'
it do
expect { job.perform }.to raise_error(RuntimeError, /no superclass method `on_failure_retry'/)
end
end
end
3 changes: 3 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@
config.before do
Resque.redis.redis.flushdb
end

config.filter_run_including focus: true
config.run_all_when_everything_filtered = true
end

0 comments on commit eeacf88

Please sign in to comment.