Sha256: 5a535bcd12aeaee9cb193498b4bfd706ecd2b81f8a73c1af60052160ab719edf
Contents?: true
Size: 1.35 KB
Versions: 22
Compression:
Stored size: 1.35 KB
Contents
require 'spec_helper' describe Taskinator::TaskWorker do def mock_task(paused=false, cancelled=false, can_complete=false) double('task', :paused? => paused, :cancelled? => cancelled, :can_complete? => can_complete) end let(:uuid) { Taskinator.generate_uuid } subject { Taskinator::TaskWorker.new(uuid) } it "should fetch the task" do task = mock_task expect(Taskinator::Task).to receive(:fetch).with(uuid) { task } allow(task).to receive(:start!) subject.perform end it "should start the task" do task = mock_task allow(Taskinator::Task).to receive(:fetch).with(uuid) { task } expect(task).to receive(:start!) subject.perform end it "should not start if paused" do task = mock_task(true, false) allow(Taskinator::Task).to receive(:fetch).with(uuid) { task } expect(task).to_not receive(:start!) subject.perform end it "should not start if cancelled" do task = mock_task(false, true) allow(Taskinator::Task).to receive(:fetch).with(uuid) { task } expect(task).to_not receive(:start!) subject.perform end it "should fail if task raises an error" do task = mock_task allow(Taskinator::Task).to receive(:fetch).with(uuid) { task } allow(task).to receive(:start!) { raise StandardError } expect { subject.perform }.to raise_error(StandardError) end end
Version data entries
22 entries across 22 versions & 1 rubygems