bumbleworks 0.0.74 → 0.0.76

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec +1 -1
  3. data/.ruby-version +1 -1
  4. data/bumbleworks.gemspec +2 -2
  5. data/lib/bumbleworks.rb +1 -0
  6. data/lib/bumbleworks/expression.rb +12 -1
  7. data/lib/bumbleworks/process.rb +10 -0
  8. data/lib/bumbleworks/process/error_record.rb +14 -0
  9. data/lib/bumbleworks/schedule.rb +58 -0
  10. data/lib/bumbleworks/task.rb +2 -1
  11. data/lib/bumbleworks/task/finder.rb +4 -0
  12. data/lib/bumbleworks/version.rb +1 -1
  13. data/lib/bumbleworks/workitem.rb +4 -0
  14. data/spec/fixtures/schedules.rb +40 -0
  15. data/spec/integration/entity_spec.rb +7 -7
  16. data/spec/integration/example_configurations_spec.rb +5 -5
  17. data/spec/integration/history_storage_spec.rb +9 -9
  18. data/spec/integration/sample_application_spec.rb +15 -15
  19. data/spec/lib/bumbleworks/configuration_spec.rb +52 -52
  20. data/spec/lib/bumbleworks/entity_spec.rb +66 -68
  21. data/spec/lib/bumbleworks/error_handler_spec.rb +1 -1
  22. data/spec/lib/bumbleworks/error_logger_spec.rb +5 -5
  23. data/spec/lib/bumbleworks/expression_spec.rb +34 -12
  24. data/spec/lib/bumbleworks/hash_storage_spec.rb +2 -2
  25. data/spec/lib/bumbleworks/participant/base_spec.rb +1 -1
  26. data/spec/lib/bumbleworks/participant/entity_interactor_spec.rb +20 -20
  27. data/spec/lib/bumbleworks/participant/error_dispatcher_spec.rb +3 -3
  28. data/spec/lib/bumbleworks/participant/local_participant_spec.rb +1 -1
  29. data/spec/lib/bumbleworks/participant_registration_spec.rb +4 -4
  30. data/spec/lib/bumbleworks/process/error_record_spec.rb +13 -0
  31. data/spec/lib/bumbleworks/process_definition_spec.rb +30 -24
  32. data/spec/lib/bumbleworks/process_spec.rb +86 -54
  33. data/spec/lib/bumbleworks/ruote/exp/broadcast_event_expression_spec.rb +2 -2
  34. data/spec/lib/bumbleworks/ruote/exp/wait_for_event_expression_spec.rb +4 -4
  35. data/spec/lib/bumbleworks/ruote_spec.rb +73 -71
  36. data/spec/lib/bumbleworks/schedule_spec.rb +124 -0
  37. data/spec/lib/bumbleworks/simple_logger_spec.rb +8 -8
  38. data/spec/lib/bumbleworks/storage_adapter_spec.rb +16 -16
  39. data/spec/lib/bumbleworks/support_spec.rb +23 -19
  40. data/spec/lib/bumbleworks/task/finder_spec.rb +46 -46
  41. data/spec/lib/bumbleworks/task_spec.rb +188 -167
  42. data/spec/lib/bumbleworks/tracker_spec.rb +41 -42
  43. data/spec/lib/bumbleworks/tree_builder_spec.rb +9 -7
  44. data/spec/lib/bumbleworks/user_spec.rb +35 -35
  45. data/spec/lib/bumbleworks/workitem_entity_storage_spec.rb +5 -5
  46. data/spec/lib/bumbleworks/workitem_spec.rb +28 -17
  47. data/spec/lib/bumbleworks_spec.rb +57 -51
  48. data/spec/spec_helper.rb +0 -1
  49. data/spec/support/shared_examples.rb +3 -3
  50. metadata +35 -54
@@ -10,6 +10,7 @@ describe Bumbleworks::Process do
10
10
  concurrence do
11
11
  admin :task => 'eat_a_hat'
12
12
  hatter :task => 'weep'
13
+ wait '40m'
13
14
  end
14
15
  end
15
16
 
@@ -24,6 +25,10 @@ describe Bumbleworks::Process do
24
25
  concurrence do
25
26
  wait_for_event :rock_caliper_delivery
26
27
  wait_for_event :speedos
28
+ wait '15m'
29
+ every '20m' do
30
+ magician :task => 'fancy_rabbit_maneuvers'
31
+ end
27
32
  end
28
33
  end
29
34
  Bumbleworks.define_process 'i_wait_for_nobody' do
@@ -54,44 +59,44 @@ describe Bumbleworks::Process do
54
59
  end
55
60
 
56
61
  it 'returns all process wfids' do
57
- described_class.ids.should == @sorted_processes.map(&:wfid)
62
+ expect(described_class.ids).to eq(@sorted_processes.map(&:wfid))
58
63
  end
59
64
 
60
65
  it 'allows pagination options' do
61
- described_class.ids(:limit => 2).should == @sorted_processes[0, 2].map(&:wfid)
62
- described_class.ids(:offset => 2).should == @sorted_processes[2, 5].map(&:wfid)
63
- described_class.ids(:limit => 2, :offset => 1).should == @sorted_processes[1, 2].map(&:wfid)
66
+ expect(described_class.ids(:limit => 2)).to eq(@sorted_processes[0, 2].map(&:wfid))
67
+ expect(described_class.ids(:offset => 2)).to eq(@sorted_processes[2, 5].map(&:wfid))
68
+ expect(described_class.ids(:limit => 2, :offset => 1)).to eq(@sorted_processes[1, 2].map(&:wfid))
64
69
  end
65
70
 
66
71
  it 'allows reverse order' do
67
- described_class.ids(:reverse => true).should == @sorted_processes.reverse.map(&:wfid)
72
+ expect(described_class.ids(:reverse => true)).to eq(@sorted_processes.reverse.map(&:wfid))
68
73
  end
69
74
 
70
75
  it 'allows combined reverse and pagination' do
71
- described_class.ids(:reverse => true, :limit => 2).should == @sorted_processes.reverse[0, 2].map(&:wfid)
72
- described_class.ids(:reverse => true, :offset => 2).should == @sorted_processes.reverse[2, 5].map(&:wfid)
73
- described_class.ids(:reverse => true, :limit => 2, :offset => 1).should == @sorted_processes.reverse[1, 2].map(&:wfid)
76
+ expect(described_class.ids(:reverse => true, :limit => 2)).to eq(@sorted_processes.reverse[0, 2].map(&:wfid))
77
+ expect(described_class.ids(:reverse => true, :offset => 2)).to eq(@sorted_processes.reverse[2, 5].map(&:wfid))
78
+ expect(described_class.ids(:reverse => true, :limit => 2, :offset => 1)).to eq(@sorted_processes.reverse[1, 2].map(&:wfid))
74
79
  end
75
80
  end
76
81
 
77
82
  describe '.count' do
78
83
  it 'returns number of processes' do
79
84
  allow(described_class).to receive(:ids).and_return([:a, :b, :c, :d])
80
- described_class.count.should == 4
85
+ expect(described_class.count).to eq(4)
81
86
  end
82
87
  end
83
88
 
84
89
  describe '.new' do
85
90
  it 'sets workflow id' do
86
91
  bp = described_class.new('apples')
87
- bp.id.should == 'apples'
92
+ expect(bp.id).to eq('apples')
88
93
  end
89
94
  end
90
95
 
91
96
  describe '#wfid' do
92
97
  it 'is aliased to id' do
93
98
  bp = described_class.new('smorgatoof')
94
- bp.wfid.should == 'smorgatoof'
99
+ expect(bp.wfid).to eq('smorgatoof')
95
100
  end
96
101
  end
97
102
 
@@ -106,13 +111,13 @@ describe Bumbleworks::Process do
106
111
  bp = Bumbleworks.launch!('error_process')
107
112
  Bumbleworks.dashboard.wait_for('error_intercepted')
108
113
  errors = bp.errors
109
- errors.map(&:class).uniq.should == [
114
+ expect(errors.map(&:class).uniq).to eq([
110
115
  Bumbleworks::Process::ErrorRecord
111
- ]
112
- errors.map(&:message).should =~ [
116
+ ])
117
+ expect(errors.map(&:message)).to match_array([
113
118
  'first error',
114
119
  'second error'
115
- ]
120
+ ])
116
121
  end
117
122
  end
118
123
 
@@ -122,8 +127,8 @@ describe Bumbleworks::Process do
122
127
  l1 = double(:workitem => 'w1')
123
128
  l2 = double(:workitem => 'w2')
124
129
  l3 = double(:workitem => 'w3')
125
- bp.stub(:leaves => [l1, l2, l3])
126
- bp.workitems.should == ['w1','w2','w3']
130
+ allow(bp).to receive_messages(:leaves => [l1, l2, l3])
131
+ expect(bp.workitems).to eq(['w1','w2','w3'])
127
132
  end
128
133
  end
129
134
 
@@ -131,7 +136,7 @@ describe Bumbleworks::Process do
131
136
  let(:entity_workitem) { Bumbleworks::Workitem.new(:fake_workitem) }
132
137
  let(:holder) {
133
138
  holder = described_class.new('nothing')
134
- holder.stub(:entity_workitem => entity_workitem)
139
+ allow(holder).to receive_messages(:entity_workitem => entity_workitem)
135
140
  holder
136
141
  }
137
142
  let(:storage_workitem) { entity_workitem }
@@ -142,7 +147,7 @@ describe Bumbleworks::Process do
142
147
  bp = Bumbleworks.launch!('food_is_an_illusion')
143
148
  Bumbleworks.dashboard.wait_for(:admin)
144
149
  expect(bp.expressions.map(&:expid)).to eq [
145
- '0', '0_1', '0_1_0', '0_1_1'
150
+ '0', '0_1', '0_1_0', '0_1_1', '0_1_2'
146
151
  ]
147
152
  expect(bp.expressions.map(&:class).uniq).to eq [
148
153
  Bumbleworks::Expression
@@ -181,7 +186,7 @@ describe Bumbleworks::Process do
181
186
  bp = Bumbleworks.launch!('food_is_an_illusion')
182
187
  Bumbleworks.dashboard.wait_for(:admin)
183
188
  expect(bp.leaves.map(&:expid)).to eq [
184
- '0_1_0', '0_1_1'
189
+ '0_1_0', '0_1_1', '0_1_2'
185
190
  ]
186
191
  expect(bp.leaves.map(&:class).uniq).to eq [
187
192
  Bumbleworks::Expression
@@ -194,13 +199,13 @@ describe Bumbleworks::Process do
194
199
  bp = described_class.new('nothing')
195
200
  w1 = double(:entity_fields => :some_fields)
196
201
  w2 = double(:entity_fields => :some_fields)
197
- bp.stub(:workitems => [w1, w2])
198
- bp.entity_workitem.should == w1
202
+ allow(bp).to receive_messages(:workitems => [w1, w2])
203
+ expect(bp.entity_workitem).to eq(w1)
199
204
  end
200
205
 
201
206
  it 'returns nil if no process' do
202
207
  bp = described_class.new('nothing')
203
- bp.entity_workitem.should be_nil
208
+ expect(bp.entity_workitem).to be_nil
204
209
  end
205
210
 
206
211
  it 'returns workitem with entity reference from process launch' do
@@ -208,7 +213,7 @@ describe Bumbleworks::Process do
208
213
  bp = Bumbleworks.launch!('going_to_the_dance', :entity => rainbow_loom)
209
214
  wait_until { bp.reload.trackers.count > 0 }
210
215
  ew = bp.entity_workitem
211
- ew.entity.should == rainbow_loom
216
+ expect(ew.entity).to eq(rainbow_loom)
212
217
  end
213
218
 
214
219
  it 'raises exception if multiple workitems have conflicting entity info' do
@@ -235,7 +240,7 @@ describe Bumbleworks::Process do
235
240
  describe '#entity' do
236
241
  it 'bubbles EntityConflict from entity_workitem' do
237
242
  bp = described_class.new('whatever')
238
- bp.stub(:entity_workitem).and_raise(Bumbleworks::Process::EntityConflict)
243
+ allow(bp).to receive(:entity_workitem).and_raise(Bumbleworks::Process::EntityConflict)
239
244
  expect {
240
245
  bp.entity
241
246
  }.to raise_error(Bumbleworks::Process::EntityConflict)
@@ -245,8 +250,21 @@ describe Bumbleworks::Process do
245
250
  describe '#tasks' do
246
251
  it 'returns task query filtered for this process' do
247
252
  bp = described_class.new('chumpy')
248
- Bumbleworks::Task.stub(:for_process).with('chumpy').and_return(:my_task_query)
249
- bp.tasks.should == :my_task_query
253
+ allow(Bumbleworks::Task).to receive(:for_process).with('chumpy').and_return(:my_task_query)
254
+ expect(bp.tasks).to eq(:my_task_query)
255
+ end
256
+ end
257
+
258
+ describe '#schedules' do
259
+ it 'returns array of all schedules for this process' do
260
+ bp1 = Bumbleworks.launch!('food_is_an_illusion')
261
+ bp2 = Bumbleworks.launch!('straightening_the_rocks')
262
+ wait_until { bp1.reload.schedules.count == 1 && bp2.reload.schedules.count == 2 }
263
+ expect(bp1.schedules.map { |s| s.process }).to eq([bp1])
264
+ expect(bp2.schedules.map { |s| s.process }).to eq([bp2, bp2])
265
+ expect(bp1.schedules.map { |s| s.original_plan }).to eq(['40m'])
266
+ expect(bp2.schedules.map { |s| s.original_plan }).to eq(['15m', '20m'])
267
+ expect(bp2.schedules.map { |s| s.repeating? }).to eq([false, true])
250
268
  end
251
269
  end
252
270
 
@@ -255,12 +273,12 @@ describe Bumbleworks::Process do
255
273
  bp1 = Bumbleworks.launch!('going_to_the_dance')
256
274
  bp2 = Bumbleworks.launch!('straightening_the_rocks')
257
275
  wait_until { bp1.reload.trackers.count == 3 && bp2.reload.trackers.count == 2 }
258
- bp1.trackers.map { |t| t.process }.should == [bp1, bp1, bp1]
259
- bp2.trackers.map { |t| t.process }.should == [bp2, bp2]
260
- bp1.trackers.map { |t| t.action }.should == ['left_tag', 'left_tag', 'dispatch']
261
- bp2.trackers.map { |t| t.action }.should == ['left_tag', 'left_tag']
262
- bp1.trackers.map { |t| t.conditions['tag'] }.should == [['an_invitation'], ['a_friend'], nil]
263
- bp2.trackers.map { |t| t.conditions['tag'] }.should == [['rock_caliper_delivery'], ['speedos']]
276
+ expect(bp1.trackers.map { |t| t.process }).to eq([bp1, bp1, bp1])
277
+ expect(bp2.trackers.map { |t| t.process }).to eq([bp2, bp2])
278
+ expect(bp1.trackers.map { |t| t.action }).to eq(['left_tag', 'left_tag', 'dispatch'])
279
+ expect(bp2.trackers.map { |t| t.action }).to eq(['left_tag', 'left_tag'])
280
+ expect(bp1.trackers.map { |t| t.conditions['tag'] }).to eq([['an_invitation'], ['a_friend'], nil])
281
+ expect(bp2.trackers.map { |t| t.conditions['tag'] }).to eq([['rock_caliper_delivery'], ['speedos']])
264
282
  end
265
283
  end
266
284
 
@@ -269,14 +287,14 @@ describe Bumbleworks::Process do
269
287
  bp1 = Bumbleworks.launch!('going_to_the_dance')
270
288
  bp2 = Bumbleworks.launch!('straightening_the_rocks')
271
289
  wait_until { bp1.reload.trackers.count == 3 && bp2.reload.trackers.count == 2 }
272
- bp1.all_subscribed_tags.should == { :global => ['an_invitation'], bp1.wfid => ['a_friend'] }
273
- bp2.all_subscribed_tags.should == { :global => ['rock_caliper_delivery', 'speedos'] }
290
+ expect(bp1.all_subscribed_tags).to eq({ :global => ['an_invitation'], bp1.wfid => ['a_friend'] })
291
+ expect(bp2.all_subscribed_tags).to eq({ :global => ['rock_caliper_delivery', 'speedos'] })
274
292
  end
275
293
 
276
294
  it 'sets global tags to empty array by default' do
277
295
  bp = Bumbleworks.launch!('i_wait_for_nobody')
278
296
  wait_until { bp.reload.tasks.count == 1 }
279
- bp.all_subscribed_tags.should == { :global => [] }
297
+ expect(bp.all_subscribed_tags).to eq({ :global => [] })
280
298
  end
281
299
  end
282
300
 
@@ -285,41 +303,41 @@ describe Bumbleworks::Process do
285
303
  bp1 = Bumbleworks.launch!('going_to_the_dance')
286
304
  bp2 = Bumbleworks.launch!('straightening_the_rocks')
287
305
  wait_until { bp1.reload.trackers.count == 3 && bp2.reload.trackers.count == 2 }
288
- bp1.subscribed_events.should == ['an_invitation']
289
- bp2.subscribed_events.should == ['rock_caliper_delivery', 'speedos']
306
+ expect(bp1.subscribed_events).to eq(['an_invitation'])
307
+ expect(bp2.subscribed_events).to eq(['rock_caliper_delivery', 'speedos'])
290
308
  end
291
309
 
292
310
  it 'returns empty array if no global tags' do
293
311
  bp = Bumbleworks.launch!('i_wait_for_nobody')
294
312
  wait_until { bp.reload.tasks.count == 1 }
295
- bp.subscribed_events.should == []
313
+ expect(bp.subscribed_events).to eq([])
296
314
  end
297
315
  end
298
316
 
299
317
  describe '#is_waiting_for?' do
300
318
  it 'returns true if event is in subscribed events' do
301
319
  bp = described_class.new('whatever')
302
- bp.stub(:subscribed_events => ['ghosts', 'mouses'])
303
- bp.is_waiting_for?('mouses').should be_true
320
+ allow(bp).to receive_messages(:subscribed_events => ['ghosts', 'mouses'])
321
+ expect(bp.is_waiting_for?('mouses')).to be_truthy
304
322
  end
305
323
 
306
324
  it 'converts symbolized queries' do
307
325
  bp = described_class.new('whatever')
308
- bp.stub(:subscribed_events => ['ghosts', 'mouses'])
309
- bp.is_waiting_for?(:ghosts).should be_true
326
+ allow(bp).to receive_messages(:subscribed_events => ['ghosts', 'mouses'])
327
+ expect(bp.is_waiting_for?(:ghosts)).to be_truthy
310
328
  end
311
329
 
312
330
  it 'returns false if event is not in subscribed events' do
313
331
  bp = described_class.new('whatever')
314
- bp.stub(:subscribed_events => ['ghosts', 'mouses'])
315
- bp.is_waiting_for?('organs').should be_false
332
+ allow(bp).to receive_messages(:subscribed_events => ['ghosts', 'mouses'])
333
+ expect(bp.is_waiting_for?('organs')).to be_falsy
316
334
  end
317
335
  end
318
336
 
319
337
  describe '#kill!' do
320
338
  it 'kills process' do
321
339
  bp = described_class.new('frogheads')
322
- Bumbleworks.should_receive(:kill_process!).with('frogheads')
340
+ expect(Bumbleworks).to receive(:kill_process!).with('frogheads')
323
341
  bp.kill!
324
342
  end
325
343
  end
@@ -327,7 +345,7 @@ describe Bumbleworks::Process do
327
345
  describe '#cancel!' do
328
346
  it 'cancels process' do
329
347
  bp = described_class.new('frogheads')
330
- Bumbleworks.should_receive(:cancel_process!).with('frogheads')
348
+ expect(Bumbleworks).to receive(:cancel_process!).with('frogheads')
331
349
  bp.cancel!
332
350
  end
333
351
  end
@@ -336,7 +354,7 @@ describe Bumbleworks::Process do
336
354
  it 'returns true if other object has same wfid' do
337
355
  bp1 = described_class.new('in_da_sky')
338
356
  bp2 = described_class.new('in_da_sky')
339
- bp1.should == bp2
357
+ expect(bp1).to eq(bp2)
340
358
  end
341
359
  end
342
360
 
@@ -351,26 +369,40 @@ describe Bumbleworks::Process do
351
369
  end
352
370
  end
353
371
 
372
+ describe '#running?' do
373
+ it 'returns true if process_status returns something' do
374
+ subject = described_class.new('frogheads')
375
+ allow(subject).to receive(:process_status).and_return(:the_status)
376
+ expect(subject.running?).to be_truthy
377
+ end
378
+
379
+ it 'returns false if process_status is nil' do
380
+ subject = described_class.new('frogheads')
381
+ allow(subject).to receive(:process_status).and_return(nil)
382
+ expect(subject.running?).to be_falsy
383
+ end
384
+ end
385
+
354
386
  describe '#process_status' do
355
387
  it 'returns a process_status instance for the wfid' do
356
388
  bp = described_class.new('frogheads')
357
- Bumbleworks.dashboard.stub(:process).with('frogheads').and_return(:the_status)
358
- bp.process_status.should == :the_status
389
+ allow(Bumbleworks.dashboard).to receive(:process).with('frogheads').and_return(:the_status)
390
+ expect(bp.process_status).to eq(:the_status)
359
391
  end
360
392
  end
361
393
 
362
394
  describe '#method_missing' do
363
395
  it 'calls method on object returned by #process_status' do
364
396
  ps = double('process_status')
365
- ps.stub(:nuffle).with(:yay).and_return(:its_a_me)
397
+ allow(ps).to receive(:nuffle).with(:yay).and_return(:its_a_me)
366
398
  bp = described_class.new('frogheads')
367
- bp.stub(:process_status => ps)
368
- bp.nuffle(:yay).should == :its_a_me
399
+ allow(bp).to receive_messages(:process_status => ps)
400
+ expect(bp.nuffle(:yay)).to eq(:its_a_me)
369
401
  end
370
402
 
371
403
  it 'falls back to method missing if no process status method' do
372
404
  bp = described_class.new('blah')
373
- bp.stub(:process_status => double('process status'))
405
+ allow(bp).to receive_messages(:process_status => double('process status'))
374
406
  expect {
375
407
  bp.kerplunk!(:oh_no)
376
408
  }.to raise_error
@@ -17,7 +17,7 @@ describe Ruote::Exp::BroadcastEventExpression do
17
17
  waiter = Bumbleworks.launch!('waiter')
18
18
  sender = Bumbleworks.launch!('sender')
19
19
  Bumbleworks.dashboard.wait_for(waiter.wfid)
20
- @tracer.should == ['amazing']
20
+ expect(@tracer).to eq(['amazing'])
21
21
  end
22
22
 
23
23
  it 'appends entity info to tag when :for_entity is true' do
@@ -33,6 +33,6 @@ describe Ruote::Exp::BroadcastEventExpression do
33
33
  waiter = Bumbleworks.launch!('waiter')
34
34
  sender = Bumbleworks.launch!('sender', :entity_type => 'PigWidget', :entity_id => 15)
35
35
  Bumbleworks.dashboard.wait_for(waiter.wfid)
36
- @tracer.should == ['amazing']
36
+ expect(@tracer).to eq(['amazing'])
37
37
  end
38
38
  end
@@ -32,7 +32,7 @@ describe Ruote::Exp::WaitForEventExpression do
32
32
  waiter = Bumbleworks.launch!('waiter')
33
33
  sender = Bumbleworks.launch!('sender')
34
34
  Bumbleworks.dashboard.wait_for(waiter.wfid)
35
- @tracer.should == ['get ready', 'oh my gosh almost there', 'hello', 'yay', 'yay2']
35
+ expect(@tracer).to eq(['get ready', 'oh my gosh almost there', 'hello', 'yay', 'yay2'])
36
36
  end
37
37
 
38
38
  it 'checks where clause' do
@@ -52,7 +52,7 @@ describe Ruote::Exp::WaitForEventExpression do
52
52
  sender2 = Bumbleworks.launch!('sender', 'special' => 3)
53
53
 
54
54
  Bumbleworks.dashboard.wait_for(waiter3.wfid)
55
- @tracer.should == ['specials! 3']
55
+ expect(@tracer).to eq(['specials! 3'])
56
56
  end
57
57
 
58
58
  it 'checks entity match' do
@@ -72,7 +72,7 @@ describe Ruote::Exp::WaitForEventExpression do
72
72
  sender2 = Bumbleworks.launch!('sender', 'entity_type' => 'Rhubarb', 'entity_id' => 'spitpickle-4boof')
73
73
 
74
74
  Bumbleworks.dashboard.wait_for(waiter3.wfid)
75
- @tracer.should == ['entities! Rhubarb,spitpickle-4boof']
75
+ expect(@tracer).to eq(['entities! Rhubarb,spitpickle-4boof'])
76
76
  end
77
77
 
78
78
  it 'appends entity info to expected tag when :for_entity is true' do
@@ -89,6 +89,6 @@ describe Ruote::Exp::WaitForEventExpression do
89
89
  sender = Bumbleworks.launch!('sender')
90
90
 
91
91
  Bumbleworks.dashboard.wait_for(waiter.wfid)
92
- @tracer.should == ['i found your tag, sucka']
92
+ expect(@tracer).to eq(['i found your tag, sucka'])
93
93
  end
94
94
  end
@@ -10,9 +10,9 @@ describe Bumbleworks::Ruote do
10
10
  end
11
11
  process = Bumbleworks.launch!('do_nothing')
12
12
  Bumbleworks.dashboard.wait_for(:lazy_guy)
13
- Bumbleworks.dashboard.process(process.wfid).should_not be_nil
13
+ expect(Bumbleworks.dashboard.process(process.wfid)).not_to be_nil
14
14
  described_class.cancel_process!(process.wfid)
15
- Bumbleworks.dashboard.process(process.wfid).should be_nil
15
+ expect(Bumbleworks.dashboard.process(process.wfid)).to be_nil
16
16
  end
17
17
 
18
18
  it 'times out if process is not cancelled in time' do
@@ -26,7 +26,7 @@ describe Bumbleworks::Ruote do
26
26
  end
27
27
  process = Bumbleworks.launch!('time_hog')
28
28
  Bumbleworks.dashboard.wait_for(:pigheaded)
29
- Bumbleworks.dashboard.process(process.wfid).should_not be_nil
29
+ expect(Bumbleworks.dashboard.process(process.wfid)).not_to be_nil
30
30
  expect {
31
31
  described_class.cancel_process!(process.wfid, :timeout => 0.5)
32
32
  }.to raise_error(Bumbleworks::Ruote::CancelTimeout)
@@ -49,21 +49,21 @@ describe Bumbleworks::Ruote do
49
49
  end
50
50
  process = Bumbleworks.launch!('do_nothing')
51
51
  Bumbleworks.dashboard.wait_for(:lazy_guy)
52
- Bumbleworks.dashboard.process(process.wfid).should_not be_nil
52
+ expect(Bumbleworks.dashboard.process(process.wfid)).not_to be_nil
53
53
  described_class.kill_process!(process.wfid)
54
- Bumbleworks.dashboard.process(process.wfid).should be_nil
54
+ expect(Bumbleworks.dashboard.process(process.wfid)).to be_nil
55
55
  end
56
56
 
57
57
  it 'times out if process is not killed in time' do
58
- Bumbleworks.dashboard.stub(:process).with('woot').and_return(:i_exist)
58
+ allow(Bumbleworks.dashboard).to receive(:process).with('woot').and_return(:i_exist)
59
59
  expect {
60
60
  described_class.kill_process!('woot', :timeout => 0.5)
61
61
  }.to raise_error(Bumbleworks::Ruote::KillTimeout)
62
62
  end
63
63
 
64
64
  it 'uses storage.remove_process if force option is true' do
65
- Bumbleworks.dashboard.storage.should_receive(:remove_process).with('woot')
66
- Bumbleworks.dashboard.stub(:process).with('woot').and_return(nil)
65
+ expect(Bumbleworks.dashboard.storage).to receive(:remove_process).with('woot')
66
+ allow(Bumbleworks.dashboard).to receive(:process).with('woot').and_return(nil)
67
67
  described_class.kill_process!('woot', :force => true)
68
68
  end
69
69
  end
@@ -82,9 +82,9 @@ describe Bumbleworks::Ruote do
82
82
  Bumbleworks.launch!("do_nothing_#{i}")
83
83
  Bumbleworks.dashboard.wait_for("lazy_guy_#{i}".to_sym)
84
84
  end
85
- Bumbleworks.dashboard.processes.count.should == 5
85
+ expect(Bumbleworks.dashboard.processes.count).to eq(5)
86
86
  described_class.cancel_all_processes!
87
- Bumbleworks.dashboard.processes.count.should == 0
87
+ expect(Bumbleworks.dashboard.processes.count).to eq(0)
88
88
  end
89
89
 
90
90
 
@@ -121,12 +121,12 @@ describe Bumbleworks::Ruote do
121
121
  Bumbleworks.dashboard.wait_for("lazy_guy_#{i}".to_sym)
122
122
  end
123
123
 
124
- Bumbleworks.dashboard.process_wfids.count.should == 5
124
+ expect(Bumbleworks.dashboard.process_wfids.count).to eq(5)
125
125
 
126
126
  described_class.cancel_all_processes!(:timeout => 30)
127
127
 
128
128
  # 4. When this is all done, all processes should be cancelled.
129
- Bumbleworks.dashboard.process_wfids.count.should == 0
129
+ expect(Bumbleworks.dashboard.process_wfids.count).to eq(0)
130
130
  end
131
131
 
132
132
  it 'times out if processes are not cancelled in time' do
@@ -140,7 +140,7 @@ describe Bumbleworks::Ruote do
140
140
  end
141
141
  Bumbleworks.launch!('time_hog')
142
142
  Bumbleworks.dashboard.wait_for(:pigheaded)
143
- Bumbleworks.dashboard.process_wfids.count.should == 1
143
+ expect(Bumbleworks.dashboard.process_wfids.count).to eq(1)
144
144
  expect {
145
145
  described_class.cancel_all_processes!(:timeout => 0.5)
146
146
  }.to raise_error(Bumbleworks::Ruote::CancelTimeout)
@@ -166,35 +166,35 @@ describe Bumbleworks::Ruote do
166
166
  Bumbleworks.launch!("do_nothing_#{i}")
167
167
  Bumbleworks.dashboard.wait_for("lazy_guy_#{i}".to_sym)
168
168
  end
169
- Bumbleworks.dashboard.processes.count.should == 5
169
+ expect(Bumbleworks.dashboard.processes.count).to eq(5)
170
170
  described_class.kill_all_processes!
171
- Bumbleworks.dashboard.processes.count.should == 0
171
+ expect(Bumbleworks.dashboard.processes.count).to eq(0)
172
172
  end
173
173
 
174
174
  it 'times out if processes are not killed in time' do
175
- Bumbleworks.dashboard.stub(:process_wfids).and_return(['immortal_wfid'])
175
+ allow(Bumbleworks.dashboard).to receive(:process_wfids).and_return(['immortal_wfid'])
176
176
  expect {
177
177
  described_class.kill_all_processes!(:timeout => 0.5)
178
178
  }.to raise_error(Bumbleworks::Ruote::KillTimeout)
179
179
  end
180
180
 
181
181
  it 'uses storage.clear if force option is true' do
182
- Bumbleworks.dashboard.stub(:process_wfids).and_return(['wfid'], [])
183
- Bumbleworks.dashboard.storage.should_receive(:clear)
182
+ allow(Bumbleworks.dashboard).to receive(:process_wfids).and_return(['wfid'], [])
183
+ expect(Bumbleworks.dashboard.storage).to receive(:clear)
184
184
  described_class.kill_all_processes!(:force => true)
185
185
  end
186
186
  end
187
187
 
188
188
  describe '.send_cancellation_message' do
189
189
  it 'sends cancel message to given wfids if method is cancel' do
190
- Bumbleworks.dashboard.should_receive(:cancel).with('wfid1')
191
- Bumbleworks.dashboard.should_receive(:cancel).with('wfid2')
190
+ expect(Bumbleworks.dashboard).to receive(:cancel).with('wfid1')
191
+ expect(Bumbleworks.dashboard).to receive(:cancel).with('wfid2')
192
192
  described_class.send_cancellation_message(:cancel, ['wfid1', 'wfid2'])
193
193
  end
194
194
 
195
195
  it 'sends kill message to given wfids if method is kill' do
196
- Bumbleworks.dashboard.should_receive(:kill).with('wfid1')
197
- Bumbleworks.dashboard.should_receive(:kill).with('wfid2')
196
+ expect(Bumbleworks.dashboard).to receive(:kill).with('wfid1')
197
+ expect(Bumbleworks.dashboard).to receive(:kill).with('wfid2')
198
198
  described_class.send_cancellation_message(:kill, ['wfid1', 'wfid2'])
199
199
  end
200
200
  end
@@ -206,58 +206,58 @@ describe Bumbleworks::Ruote do
206
206
  end
207
207
 
208
208
  it 'creates a new dashboard' do
209
- described_class.dashboard.should be_an_instance_of(Ruote::Dashboard)
209
+ expect(described_class.dashboard).to be_an_instance_of(Ruote::Dashboard)
210
210
  end
211
211
 
212
212
  it 'does not start a worker by default' do
213
- described_class.dashboard.worker.should be_nil
213
+ expect(described_class.dashboard.worker).to be_nil
214
214
  end
215
215
  end
216
216
 
217
217
  describe '.start_worker!' do
218
218
  it 'adds new worker to dashboard and returns worker' do
219
- described_class.dashboard.worker.should be_nil
219
+ expect(described_class.dashboard.worker).to be_nil
220
220
  new_worker = described_class.start_worker!
221
- new_worker.should be_an_instance_of(Ruote::Worker)
222
- described_class.dashboard.worker.should == new_worker
221
+ expect(new_worker).to be_an_instance_of(Ruote::Worker)
222
+ expect(described_class.dashboard.worker).to eq(new_worker)
223
223
  end
224
224
 
225
225
  it 'runs in current thread if :join option is true' do
226
- ::Ruote::Worker.stub(:new).and_return(worker_double = double('worker'))
227
- worker_double.should_receive(:run)
226
+ allow(::Ruote::Worker).to receive(:new).and_return(worker_double = double('worker'))
227
+ expect(worker_double).to receive(:run)
228
228
  described_class.start_worker!(:join => true)
229
229
  end
230
230
 
231
231
  it 'runs in new thread and returns worker if :join option not true' do
232
- ::Ruote::Worker.stub(:new).and_return(worker_double = double('worker'))
233
- worker_double.should_receive(:run_in_thread)
234
- described_class.start_worker!.should == worker_double
232
+ allow(::Ruote::Worker).to receive(:new).and_return(worker_double = double('worker'))
233
+ expect(worker_double).to receive(:run_in_thread)
234
+ expect(described_class.start_worker!).to eq(worker_double)
235
235
  end
236
236
 
237
237
  it 'sets dashboard to noisy if :verbose option true' do
238
- described_class.dashboard.should_receive(:noisy=).with(true)
238
+ expect(described_class.dashboard).to receive(:noisy=).with(true)
239
239
  described_class.start_worker!(:verbose => true)
240
240
  end
241
241
 
242
242
  it 'registers error handler' do
243
- described_class.should_receive(:register_error_dispatcher)
243
+ expect(described_class).to receive(:register_error_dispatcher)
244
244
  described_class.start_worker!
245
245
  end
246
246
 
247
247
  it 'calls set_up_storage_history' do
248
- described_class.should_receive(:set_up_storage_history)
248
+ expect(described_class).to receive(:set_up_storage_history)
249
249
  described_class.start_worker!
250
250
  end
251
251
 
252
252
  it 'does not add another error_dispatcher if already registered' do
253
253
  described_class.register_participants
254
254
  described_class.start_worker!
255
- described_class.dashboard.participant_list.map(&:classname).should == [
255
+ expect(described_class.dashboard.participant_list.map(&:classname)).to eq([
256
256
  'Bumbleworks::ErrorDispatcher',
257
257
  'Bumbleworks::EntityInteractor',
258
258
  'Bumbleworks::StorageParticipant'
259
- ]
260
- Bumbleworks.dashboard.on_error.flatten[2].should == 'error_dispatcher'
259
+ ])
260
+ expect(Bumbleworks.dashboard.on_error.flatten[2]).to eq('error_dispatcher')
261
261
  end
262
262
  end
263
263
 
@@ -265,8 +265,8 @@ describe Bumbleworks::Ruote do
265
265
  it 'adds a storage history service to the dashboard if storage adapter allows it' do
266
266
  storage_adapter = double('adapter', :allow_history_storage? => true)
267
267
  Bumbleworks.storage_adapter = storage_adapter
268
- described_class.stub(:storage => Ruote::HashStorage.new({}))
269
- Bumbleworks.dashboard.should_receive(:add_service).with(
268
+ allow(described_class).to receive_messages(:storage => Ruote::HashStorage.new({}))
269
+ expect(Bumbleworks.dashboard).to receive(:add_service).with(
270
270
  'history', 'ruote/log/storage_history', 'Ruote::StorageHistory'
271
271
  )
272
272
  described_class.set_up_storage_history
@@ -275,16 +275,16 @@ describe Bumbleworks::Ruote do
275
275
  it 'does not add a storage history service to the dashboard if not allowed' do
276
276
  storage_adapter = double('adapter', :allow_history_storage? => false)
277
277
  Bumbleworks.storage_adapter = storage_adapter
278
- described_class.stub(:storage => Ruote::HashStorage.new({}))
279
- Bumbleworks.dashboard.should_receive(:add_service).never
278
+ allow(described_class).to receive_messages(:storage => Ruote::HashStorage.new({}))
279
+ expect(Bumbleworks.dashboard).to receive(:add_service).never
280
280
  described_class.set_up_storage_history
281
281
  end
282
282
 
283
283
  it 'does not add a storage history service to the dashboard if turned off in config' do
284
284
  storage_adapter = double('adapter', :allow_history_storage? => true)
285
285
  Bumbleworks.storage_adapter = storage_adapter
286
- described_class.stub(:storage => Ruote::HashStorage.new({}))
287
- Bumbleworks.dashboard.should_receive(:add_service).never
286
+ allow(described_class).to receive_messages(:storage => Ruote::HashStorage.new({}))
287
+ expect(Bumbleworks.dashboard).to receive(:add_service).never
288
288
  Bumbleworks.store_history = false
289
289
  described_class.set_up_storage_history
290
290
  end
@@ -298,15 +298,15 @@ describe Bumbleworks::Ruote do
298
298
  catchall 'NewCatchall'
299
299
  }
300
300
 
301
- described_class.dashboard.participant_list.should be_empty
301
+ expect(described_class.dashboard.participant_list).to be_empty
302
302
  described_class.register_participants &registration_block
303
- described_class.dashboard.participant_list.should have(6).items
304
- described_class.dashboard.participant_list.map(&:classname).should == [
303
+ expect(described_class.dashboard.participant_list.size).to eq(6)
304
+ expect(described_class.dashboard.participant_list.map(&:classname)).to eq([
305
305
  'Bumbleworks::ErrorDispatcher',
306
306
  'Bumbleworks::EntityInteractor',
307
307
  'BeesHoney', 'MapleSyrup', 'NewCatchall',
308
308
  'Bumbleworks::StorageParticipant'
309
- ]
309
+ ])
310
310
  end
311
311
 
312
312
  it 'does not add storage participant catchall if already exists' do
@@ -315,32 +315,33 @@ describe Bumbleworks::Ruote do
315
315
  catchall
316
316
  }
317
317
 
318
- described_class.dashboard.participant_list.should be_empty
318
+ expect(described_class.dashboard.participant_list).to be_empty
319
319
  described_class.register_participants &registration_block
320
- described_class.dashboard.participant_list.should have(4).items
321
- described_class.dashboard.participant_list.map(&:classname).should == [
320
+ expect(described_class.dashboard.participant_list.size).to eq(4)
321
+ expect(described_class.dashboard.participant_list.map(&:classname)).to eq([
322
322
  'Bumbleworks::ErrorDispatcher', 'Bumbleworks::EntityInteractor', 'BeesHoney', 'Ruote::StorageParticipant'
323
- ]
323
+ ])
324
324
  end
325
325
 
326
326
  it 'adds catchall and error_handler participants if block is nil' do
327
- described_class.dashboard.participant_list.should be_empty
327
+ expect(described_class.dashboard.participant_list).to be_empty
328
328
  described_class.register_participants &nil
329
- described_class.dashboard.participant_list.should have(3).item
330
- described_class.dashboard.participant_list.map(&:classname).should ==
329
+ expect(described_class.dashboard.participant_list.size).to eq(3)
330
+ expect(described_class.dashboard.participant_list.map(&:classname)).to eq(
331
331
  ['Bumbleworks::ErrorDispatcher', 'Bumbleworks::EntityInteractor', 'Bumbleworks::StorageParticipant']
332
+ )
332
333
  end
333
334
  end
334
335
 
335
336
  describe '.register_error_dispatcher', dev:true do
336
337
  it 'registers the error handler participant' do
337
338
  described_class.register_error_dispatcher
338
- Bumbleworks.dashboard.participant_list.map(&:classname).should include('Bumbleworks::ErrorDispatcher')
339
+ expect(Bumbleworks.dashboard.participant_list.map(&:classname)).to include('Bumbleworks::ErrorDispatcher')
339
340
  end
340
341
 
341
342
  it 'it sets the global Ruote on_error to the error_dispatcher' do
342
343
  described_class.register_error_dispatcher
343
- Bumbleworks.dashboard.on_error.flatten[2].should == 'error_dispatcher'
344
+ expect(Bumbleworks.dashboard.on_error.flatten[2]).to eq('error_dispatcher')
344
345
  end
345
346
 
346
347
  it 'does not override existing error_dispatcher' do
@@ -348,8 +349,9 @@ describe Bumbleworks::Ruote do
348
349
  error_dispatcher 'Whatever'
349
350
  end
350
351
  described_class.register_error_dispatcher
351
- Bumbleworks.dashboard.participant_list.map(&:classname).should ==
352
+ expect(Bumbleworks.dashboard.participant_list.map(&:classname)).to eq(
352
353
  ['Bumbleworks::EntityInteractor', 'Whatever', 'Bumbleworks::StorageParticipant']
354
+ )
353
355
 
354
356
  end
355
357
  end
@@ -365,11 +367,11 @@ describe Bumbleworks::Ruote do
365
367
  storage = {}
366
368
  adapter = double('Adapter')
367
369
  options = { :thing => 'yay' }
368
- adapter.stub(:new_storage).with(storage, options).and_return(driven_storage)
370
+ allow(adapter).to receive(:new_storage).with(storage, options).and_return(driven_storage)
369
371
  Bumbleworks.storage = storage
370
372
  Bumbleworks.storage_adapter = adapter
371
373
  Bumbleworks.storage_options = options
372
- described_class.storage.should == driven_storage
374
+ expect(described_class.storage).to eq(driven_storage)
373
375
  end
374
376
  end
375
377
 
@@ -379,15 +381,15 @@ describe Bumbleworks::Ruote do
379
381
  end
380
382
 
381
383
  it 'tells dashboard to launch process' do
382
- described_class.dashboard.should_receive(:launch).with(@pdef.tree, 'variable' => 'neat')
384
+ expect(described_class.dashboard).to receive(:launch).with(@pdef.tree, 'variable' => 'neat')
383
385
  described_class.launch('foo', 'variable' => 'neat')
384
386
  end
385
387
 
386
388
  it 'sets catchall if needed' do
387
- described_class.dashboard.participant_list.should be_empty
389
+ expect(described_class.dashboard.participant_list).to be_empty
388
390
  described_class.launch('foo')
389
- described_class.dashboard.participant_list.should have(1).item
390
- described_class.dashboard.participant_list.first.classname.should == 'Bumbleworks::StorageParticipant'
391
+ expect(described_class.dashboard.participant_list.size).to eq(1)
392
+ expect(described_class.dashboard.participant_list.first.classname).to eq('Bumbleworks::StorageParticipant')
391
393
  end
392
394
  end
393
395
 
@@ -395,11 +397,11 @@ describe Bumbleworks::Ruote do
395
397
  it 'purges and shuts down storage, then resets storage' do
396
398
  old_storage = double('Storage')
397
399
  allow(described_class).to receive(:initialize_storage_adapter).and_return(old_storage)
398
- old_storage.should_receive(:purge!)
399
- old_storage.should_receive(:shutdown)
400
+ expect(old_storage).to receive(:purge!)
401
+ expect(old_storage).to receive(:shutdown)
400
402
  described_class.reset!
401
403
  allow(described_class).to receive(:initialize_storage_adapter).and_return(:new_storage)
402
- described_class.storage.should == :new_storage
404
+ expect(described_class.storage).to eq(:new_storage)
403
405
  # clean up
404
406
  described_class.instance_variable_set(:@storage, nil)
405
407
  end
@@ -413,9 +415,9 @@ describe Bumbleworks::Ruote do
413
415
 
414
416
  it 'shuts down dashboard and detaches' do
415
417
  old_dashboard = described_class.dashboard
416
- old_dashboard.should_receive(:shutdown)
418
+ expect(old_dashboard).to receive(:shutdown)
417
419
  described_class.reset!
418
- described_class.dashboard.should_not == old_dashboard
420
+ expect(described_class.dashboard).not_to eq(old_dashboard)
419
421
  end
420
422
 
421
423
  it 'skips shutting down dashboard if no dashboard' do
@@ -428,9 +430,9 @@ describe Bumbleworks::Ruote do
428
430
  it 'skips shutting down dashboard if dashboard can not be shutdown' do
429
431
  dashboard = double('dashboard', :respond_to? => false)
430
432
  described_class.instance_variable_set(:@dashboard, dashboard)
431
- dashboard.should_receive(:shutdown).never
433
+ expect(dashboard).to receive(:shutdown).never
432
434
  described_class.reset!
433
- described_class.dashboard.should_not == dashboard
435
+ expect(described_class.dashboard).not_to eq(dashboard)
434
436
  end
435
437
  end
436
438
  end