|
92 | 92 | Taskinator.queue_adapter = :test_queue_worker
|
93 | 93 | end
|
94 | 94 |
|
| 95 | + context "before_started" do |
| 96 | + let(:definition) { TestDefinitions::TaskBeforeStarted } |
| 97 | + subject { definition.create_process } |
| 98 | + |
| 99 | + it "invokes before_started task" do |
| 100 | + expect(subject.before_started_tasks.count).to eq(1) |
| 101 | + expect_any_instance_of(definition).to receive(:task_before_started) |
| 102 | + |
| 103 | + expect { |
| 104 | + subject.enqueue! |
| 105 | + }.to change { Taskinator.queue.tasks.length }.by(2) |
| 106 | + end |
| 107 | + end |
| 108 | + |
| 109 | + context "after_completed" do |
| 110 | + let(:definition) { TestDefinitions::TaskAfterCompleted } |
| 111 | + subject { definition.create_process } |
| 112 | + |
| 113 | + it "invokes after_completed task" do |
| 114 | + expect(subject.after_completed_tasks.count).to eq(1) |
| 115 | + expect_any_instance_of(definition).to receive(:task_after_completed) |
| 116 | + |
| 117 | + expect { |
| 118 | + subject.enqueue! |
| 119 | + }.to change { Taskinator.queue.tasks.length }.by(2) |
| 120 | + end |
| 121 | + end |
| 122 | + |
| 123 | + context "after_failed" do |
| 124 | + let(:definition) { TestDefinitions::TaskAfterFailed } |
| 125 | + subject { definition.create_process } |
| 126 | + |
| 127 | + it "invokes after_failed task" do |
| 128 | + expect(subject.after_failed_tasks.count).to eq(1) |
| 129 | + expect_any_instance_of(definition).to receive(:task_after_failed) |
| 130 | + |
| 131 | + expect { |
| 132 | + begin |
| 133 | + subject.enqueue! |
| 134 | + rescue TestDefinitions::TestTaskFailed |
| 135 | + # ignore error |
| 136 | + end |
| 137 | + }.to change { Taskinator.queue.tasks.length }.by(2) |
| 138 | + end |
| 139 | + end |
| 140 | + |
95 | 141 | context "empty subprocesses" do
|
96 | 142 |
|
97 | 143 | context "sequential" do
|
|
133 | 179 | end
|
134 | 180 |
|
135 | 181 | end
|
| 182 | + |
| 183 | + context "subprocesses" do |
| 184 | + |
| 185 | + context "before_started" do |
| 186 | + let(:definition) { TestDefinitions::TaskBeforeStartedSubProcess } |
| 187 | + subject { definition.create_process } |
| 188 | + |
| 189 | + it "invokes before_started task" do |
| 190 | + expect_any_instance_of(definition).to receive(:task_before_started) |
| 191 | + |
| 192 | + expect { |
| 193 | + subject.enqueue! |
| 194 | + }.to change { Taskinator.queue.tasks.length }.by(1) |
| 195 | + end |
| 196 | + end |
| 197 | + |
| 198 | + context "after_completed" do |
| 199 | + let(:definition) { TestDefinitions::TaskAfterCompletedSubProcess } |
| 200 | + subject { definition.create_process } |
| 201 | + |
| 202 | + it "invokes after_completed task" do |
| 203 | + expect_any_instance_of(definition).to receive(:task_after_completed) |
| 204 | + |
| 205 | + expect { |
| 206 | + subject.enqueue! |
| 207 | + }.to change { Taskinator.queue.tasks.length }.by(2) |
| 208 | + end |
| 209 | + end |
| 210 | + |
| 211 | + context "after_failed" do |
| 212 | + let(:definition) { TestDefinitions::TaskAfterFailedSubProcess } |
| 213 | + subject { definition.create_process } |
| 214 | + |
| 215 | + it "invokes after_failed task" do |
| 216 | + expect_any_instance_of(definition).to receive(:task_after_failed) |
| 217 | + |
| 218 | + expect { |
| 219 | + begin |
| 220 | + subject.enqueue! |
| 221 | + rescue TestDefinitions::TestTaskFailed |
| 222 | + # ignore error |
| 223 | + end |
| 224 | + }.to change { Taskinator.queue.tasks.length }.by(2) |
| 225 | + end |
| 226 | + end |
| 227 | + |
| 228 | + end |
| 229 | + |
136 | 230 | end
|
137 | 231 |
|
138 | 232 | describe "statuses" do
|
|
0 commit comments