Sha256: 5ee1347d1a4048ba394480fbda13c321309f5b66fcdbb3a39a5996a3c2b8381f

Contents?: true

Size: 1.13 KB

Versions: 5

Compression:

Stored size: 1.13 KB

Contents

require_relative '../../../../../../app/models/resque_web/plugins/'\
                   'resque_scheduler/job_finder/working_job_finder'

describe ResqueWeb::Plugins::ResqueScheduler::JobFinder::WorkingJobFinder do
  before do
    Resque.enqueue(OngoingJob)
    @worker_thread = Thread.new do
      worker = Resque::Worker.new '*'
      worker.term_child = 1
      worker.work 0.1
    end
    sleep 0.2
  end

  after do
    @worker_thread.kill
    reset_the_resque_schedule
  end

  it 'finds a working job when the search term matches' do
    finder = described_class.new('going')
    expect(finder.find_jobs.first['class']).to eq 'OngoingJob'
  end

  it 'does not find a working job when the search term does not match' do
    finder = described_class.new('donkey')
    expect(finder.find_jobs).to be_empty
  end

  it 'adds the queue name to the returned jobs' do
    finder = described_class.new('going')
    expect(finder.find_jobs.first['queue']).to eq 'quick'
  end

  it 'sets the where_at value to "working" for the returned jobs' do
    finder = described_class.new('going')
    expect(finder.find_jobs.first['where_at']).to eq 'working'
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
resque-scheduler-web-1.1.0 spec/models/resque_web/plugins/resque_scheduler/job_finder/working_job_finder_spec.rb
resque-scheduler-web-1.0.1 spec/models/resque_web/plugins/resque_scheduler/job_finder/working_job_finder_spec.rb
resque-scheduler-web-1.0.0 spec/models/resque_web/plugins/resque_scheduler/job_finder/working_job_finder_spec.rb
resque-scheduler-web-0.0.4 spec/models/resque_web/plugins/resque_scheduler/job_finder/working_job_finder_spec.rb
resque-scheduler-web-0.0.3 spec/models/resque_web/plugins/resque_scheduler/job_finder/working_job_finder_spec.rb