Sha256: 900fdbda6b43c5b7380234db673a00612d09a8db7e01fd056d41b5aa21e0e324
Contents?: true
Size: 1.64 KB
Versions: 3
Compression:
Stored size: 1.64 KB
Contents
require 'spec_helper' require 'celluloid' require 'writefully/tools' module Writefully module Tools describe Dispatcher do let(:job) { { worker: :journalists, message: { resource: 'posts', slug: '1-hash-selector-pattern' } }} let(:retry_data) { { worker: job[:workeer], message: job[:message].merge({ tries: 2, run: false }) } } describe "#run_job" do it "should call dispatch" do Dispatcher.any_instance.stub(:job).and_return(job) Dispatcher.any_instance.stub(:retry_job).and_return(false) Dispatcher.any_instance.stub(:dispatch).and_return(true) dispatch = Dispatcher.new expect(dispatch.run_job).to be true dispatch.terminate end it "should call retry_job" do Dispatcher.any_instance.stub(:job).and_return(retry_data) Dispatcher.any_instance.stub(:dispatch).and_return(false) Dispatcher.any_instance.stub(:retry_job).and_return(true) dispatch = Dispatcher.new expect(dispatch.run_job).to be true dispatch.terminate end end it "should be job and valid" do Dispatcher.any_instance.stub(:job).and_return(job) dispatch = Dispatcher.new expect(dispatch.job_valid?).to be true expect(dispatch.retry_valid?).to be false dispatch.terminate end it "should be retry" do Dispatcher.any_instance.stub(:job).and_return(retry_data) dispatch = Dispatcher.new expect(dispatch.retry_valid?).to be true dispatch.terminate end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
writefully-0.8.2 | spec/lib/writefully/tools/dispatcher_spec.rb |
writefully-0.8.1 | spec/lib/writefully/tools/dispatcher_spec.rb |
writefully-0.8.0 | spec/lib/writefully/tools/dispatcher_spec.rb |