spec/job_spec.rb in pgjob-0.1.0 vs spec/job_spec.rb in pgjob-0.1.1

- old
+ new

@@ -26,20 +26,48 @@ }.should raise_error end end describe '#status' do - it 'returns' do + it 'running' do id = @job.create("test", key: 'value') - @job.status(id).should == :wait + + @job.status(id, :running, 'info') + + @job.running?(id).should be_true + @job.finished?(id).should be_false + @job.success?(id).should be_false + @job.failed?(id).should be_false + + @job.status(id).should == 'info' end - it 'sets' do + it 'success' do id = @job.create("test", key: 'value') - @job.status(id, :running) - @job.status(id).should == :running + + @job.status(id, :success, 'info') + + @job.running?(id).should be_false + @job.finished?(id).should be_true + @job.success?(id).should be_true + @job.failed?(id).should be_false + + @job.status(id).should == 'info' end + + it 'failed' do + id = @job.create("test", key: 'value') + + @job.status(id, :failed, 'info') + + @job.running?(id).should be_false + @job.finished?(id).should be_true + @job.success?(id).should be_false + @job.failed?(id).should be_true + + @job.status(id).should == 'info' + end end it '#name' do id = @job.create("test", key: 'value') @job.name(id).should == 'test' @@ -73,8 +101,16 @@ it 'escape' do id = @job.create("test") hard = ['"', "'", '#', '@', '!', "\n"].join @job.add_log(id, hard) @job.log(id).should == hard + end + + it "log + status" do + id = @job.create("test") + @job.add_log(id, 'msg1') + @job.status(id, :success, 'done') + @job.add_log(id, 'msg2') + @job.log(id).should == "msg1\n[mode] success - done\nmsg2" end end end