spec/models/massive/process_spec.rb in massive-0.1.0 vs spec/models/massive/process_spec.rb in massive-0.1.1

- old
+ new

@@ -7,10 +7,16 @@ context "when there are steps" do let!(:first_step) { process.steps.build } let!(:second_step) { process.steps.build } let!(:third_step) { process.steps.build } + before do + first_step.stub(:reload).and_return(first_step) + second_step.stub(:reload).and_return(second_step) + third_step.stub(:reload).and_return(third_step) + end + context "and none of them are completed" do it "enqueues the first step" do first_step.should_receive(:enqueue) process.enqueue_next end @@ -171,16 +177,33 @@ context "when the steps are incompleted steps" do its(:completed?) { should be_false } end - context "when therere are no incompleted steps" do + context "when there are no incompleted steps" do before do step_1.update_attributes(finished_at: Time.now, failed_at: nil) step_2.update_attributes(finished_at: Time.now, failed_at: nil) end its(:completed?) { should be_true } + end + end + + describe "#failed?" do + let!(:step_1) { process.steps.build } + let!(:step_2) { process.steps.build } + + before { process.save } + + context "when the steps not failed" do + its(:failed?) { should be_false } + end + + context "when any step failed" do + before { step_2.update_attributes(failed_at: Time.now) } + + its(:failed?) { should be_true } end end describe "#cancel" do let!(:now) do