mirror of
https://github.com/plashchynski/crono.git
synced 2026-04-22 16:58:42 +02:00
Fix args
This commit is contained in:
@@ -12,12 +12,19 @@ class TestFailingJob
|
||||
end
|
||||
end
|
||||
|
||||
class TestNoArgsJob
|
||||
def perform
|
||||
puts 'Test!'
|
||||
end
|
||||
end
|
||||
|
||||
describe Crono::Job do
|
||||
let(:period) { Crono::Period.new(2.day, at: '15:00') }
|
||||
let(:job_args) {[{some: 'data'}]}
|
||||
let(:job) { Crono::Job.new(TestJob, period, []) }
|
||||
let(:job_with_args) { Crono::Job.new(TestJob, period, job_args) }
|
||||
let(:failing_job) { Crono::Job.new(TestFailingJob, period, []) }
|
||||
let(:not_args_job) { Crono::Job.new(TestJob, period) }
|
||||
|
||||
it 'should contain performer and period' do
|
||||
expect(job.performer).to be TestJob
|
||||
@@ -70,6 +77,10 @@ describe Crono::Job do
|
||||
test_preform_job_twice
|
||||
end
|
||||
|
||||
it 'should execute twice without args' do
|
||||
test_preform_job_twice not_args_job
|
||||
end
|
||||
|
||||
it 'should execute twice without initialize execution_interval' do
|
||||
test_preform_job_twice
|
||||
end
|
||||
@@ -88,10 +99,10 @@ describe Crono::Job do
|
||||
expect(thread).to be_stop
|
||||
end
|
||||
|
||||
def test_preform_job_twice
|
||||
expect(job).to receive(:perform_job).twice
|
||||
job.perform.join
|
||||
thread = job.perform.join
|
||||
def test_preform_job_twice(jon_instance = job)
|
||||
expect(jon_instance).to receive(:perform_job).twice
|
||||
jon_instance.perform.join
|
||||
thread = jon_instance.perform.join
|
||||
expect(thread).to be_stop
|
||||
end
|
||||
end
|
||||
|
||||
@@ -26,13 +26,19 @@ describe Crono::PerformerProxy do
|
||||
end
|
||||
|
||||
it 'should add job with args to schedule' do
|
||||
expect(Crono::Job).to receive(:new).with(TestJob, kind_of(Crono::Period), [:some, {some: 'data'}], nil)
|
||||
expect(Crono::Job).to receive(:new).with(TestJob, kind_of(Crono::Period), :some, { some: 'data' })
|
||||
allow(Crono.scheduler).to receive(:add_job)
|
||||
Crono.perform(TestJob, :some, {some: 'data'}).every(2.days, at: '15:30')
|
||||
Crono.perform(TestJob, :some, { some: 'data' }).every(2.days, at: '15:30')
|
||||
end
|
||||
|
||||
it 'should add job without args to schedule' do
|
||||
expect(Crono::Job).to receive(:new).with(TestJob, kind_of(Crono::Period), nil, nil)
|
||||
allow(Crono.scheduler).to receive(:add_job)
|
||||
Crono.perform(TestJob).every(2.days, at: '15:30')
|
||||
end
|
||||
|
||||
it 'should add job with options to schedule' do
|
||||
expect(Crono::Job).to receive(:new).with(TestJob, kind_of(Crono::Period), [], {some_option: true})
|
||||
expect(Crono::Job).to receive(:new).with(TestJob, kind_of(Crono::Period), nil, { some_option: true })
|
||||
allow(Crono.scheduler).to receive(:add_job)
|
||||
Crono.perform(TestJob).with_options(some_option: true).every(2.days, at: '15:30')
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user