bumbleworks 0.0.74 → 0.0.76

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -3,7 +3,7 @@ describe Bumbleworks::ErrorHandler do
3
3
  let(:workitem) { double }
4
4
  describe '#initialize' do
5
5
  it 'sets workitem' do
6
- subject.workitem.should == workitem
6
+ expect(subject.workitem).to eq(workitem)
7
7
  end
8
8
  end
9
9
 
@@ -8,7 +8,7 @@ describe Bumbleworks::ErrorLogger do
8
8
  end
9
9
 
10
10
  it 'calls registered logger and logs error information' do
11
- Bumbleworks.logger.should_receive(:error).with({
11
+ expect(Bumbleworks.logger).to receive(:error).with({
12
12
  :actor => 'armadillo',
13
13
  :action => 'process error',
14
14
  :target_type => nil,
@@ -20,8 +20,8 @@ describe Bumbleworks::ErrorLogger do
20
20
  end
21
21
 
22
22
  it 'sets target to entity if found' do
23
- workitem.stub(:fields => {:entity_id => 1234, :entity_type => 'Lizards'})
24
- Bumbleworks.logger.should_receive(:error).with(hash_including({
23
+ allow(workitem).to receive_messages(:fields => {:entity_id => 1234, :entity_type => 'Lizards'})
24
+ expect(Bumbleworks.logger).to receive(:error).with(hash_including({
25
25
  :target_type => 'Lizards',
26
26
  :target_id => 1234,
27
27
  }))
@@ -30,7 +30,7 @@ describe Bumbleworks::ErrorLogger do
30
30
  end
31
31
 
32
32
  it 'does nothing if logger is not registered' do
33
- Bumbleworks.stub(:logger)
34
- subject.on_error.should == nil
33
+ allow(Bumbleworks).to receive(:logger)
34
+ expect(subject.on_error).to eq(nil)
35
35
  end
36
36
  end
@@ -3,15 +3,37 @@ describe Bumbleworks::Expression do
3
3
  let(:fexp) { double('FlowExpression', :fei => fei, :tree => :a_tree) }
4
4
  subject { described_class.new(fexp) }
5
5
 
6
+ describe '.from_fei' do
7
+ it 'returns instance generated from FlowExpressionId' do
8
+ allow(::Ruote::Exp::FlowExpression).to receive(:fetch).
9
+ with(Bumbleworks.dashboard.context, fei).and_return(fexp)
10
+ expect(described_class.from_fei(fei)).to eq(described_class.new(fexp))
11
+ end
12
+ end
13
+
14
+ describe '#==' do
15
+ it 'returns true if other object has same flow expression id' do
16
+ exp1 = described_class.new(fexp)
17
+ exp2 = described_class.new(double('FlowExpression', :fei => fei))
18
+ expect(exp1).to eq(exp2)
19
+ end
20
+
21
+ it 'returns false if other object has different flow expression id' do
22
+ exp1 = described_class.new(fexp)
23
+ exp2 = described_class.new(double('FlowExpression', :fei => double(:expid => '4')))
24
+ expect(exp1).not_to eq(exp2)
25
+ end
26
+ end
27
+
6
28
  describe '#expid' do
7
29
  it 'returns expid from fei' do
8
- subject.expid.should == '1_2_3'
30
+ expect(subject.expid).to eq('1_2_3')
9
31
  end
10
32
  end
11
33
 
12
34
  describe '#process' do
13
35
  it 'returns process for expression wfid' do
14
- subject.process.should == Bumbleworks::Process.new('snooks')
36
+ expect(subject.process).to eq(Bumbleworks::Process.new('snooks'))
15
37
  end
16
38
  end
17
39
 
@@ -24,44 +46,44 @@ describe Bumbleworks::Expression do
24
46
  describe '#error' do
25
47
  it 'returns error from process that matches fei' do
26
48
  process = double
27
- process.stub(:errors => [
49
+ allow(process).to receive_messages(:errors => [
28
50
  double(:fei => :not_me, :message => 'alarming!'),
29
51
  double(:fei => fei, :message => 'boo!'),
30
52
  double(:fei => :also_not_me, :message => 'yippee!')
31
53
  ])
32
- subject.stub(:process => process)
33
- subject.error.message.should == 'boo!'
54
+ allow(subject).to receive_messages(:process => process)
55
+ expect(subject.error.message).to eq('boo!')
34
56
  end
35
57
 
36
58
  it 'returns nil if no error during this expression' do
37
59
  process = double
38
- process.stub(:errors => [
60
+ allow(process).to receive_messages(:errors => [
39
61
  double(:fei => :not_me, :message => 'alarming!'),
40
62
  double(:fei => :also_not_me, :message => 'yippee!')
41
63
  ])
42
- subject.stub(:process => process)
43
- subject.error.should be_nil
64
+ allow(subject).to receive_messages(:process => process)
65
+ expect(subject.error).to be_nil
44
66
  end
45
67
  end
46
68
 
47
69
  describe '#cancel!' do
48
70
  it 'cancels the expression' do
49
- Bumbleworks.dashboard.should_receive(:cancel_expression).with(fei)
71
+ expect(Bumbleworks.dashboard).to receive(:cancel_expression).with(fei)
50
72
  subject.cancel!
51
73
  end
52
74
  end
53
75
 
54
76
  describe '#kill!' do
55
77
  it 'kills the expression' do
56
- Bumbleworks.dashboard.should_receive(:kill_expression).with(fei)
78
+ expect(Bumbleworks.dashboard).to receive(:kill_expression).with(fei)
57
79
  subject.kill!
58
80
  end
59
81
  end
60
82
 
61
83
  describe '#workitem' do
62
84
  it 'returns the workitem as applied to this expression' do
63
- fexp.stub(:applied_workitem).and_return(:something_raw)
64
- subject.workitem.should == Bumbleworks::Workitem.new(:something_raw)
85
+ allow(fexp).to receive(:applied_workitem).and_return(:something_raw)
86
+ expect(subject.workitem).to eq(Bumbleworks::Workitem.new(:something_raw))
65
87
  end
66
88
  end
67
89
  end
@@ -1,11 +1,11 @@
1
1
  describe Bumbleworks::HashStorage do
2
2
  describe '.allow_history_storage?' do
3
3
  it 'returns false' do
4
- described_class.allow_history_storage?.should be_false
4
+ expect(described_class.allow_history_storage?).to be_falsy
5
5
  end
6
6
 
7
7
  it 'is a Bumbleworks::StorageAdapter' do
8
- described_class.superclass.should == Bumbleworks::StorageAdapter
8
+ expect(described_class.superclass).to eq(Bumbleworks::StorageAdapter)
9
9
  end
10
10
  end
11
11
  end
@@ -1,6 +1,6 @@
1
1
  describe Bumbleworks::Participant do
2
2
  it 'includes Bumbleworks::LocalParticipant' do
3
- described_class.included_modules.should include(Bumbleworks::LocalParticipant)
3
+ expect(described_class.included_modules).to include(Bumbleworks::LocalParticipant)
4
4
  end
5
5
 
6
6
  it 'defines #on_cancel' do
@@ -1,89 +1,89 @@
1
1
  describe Bumbleworks::EntityInteractor do
2
2
  let(:entity) { double('entity', :cheek_depth => 'crazy deep') }
3
3
  let(:workitem) { Ruote::Workitem.new('fields' => { 'params' => { 'method' => 'cheek_depth' }}) }
4
- subject { part = described_class.new; part.stub(:entity => entity, :reply => nil); part }
4
+ subject { part = described_class.new; allow(part).to receive_messages(:entity => entity, :reply => nil); part }
5
5
 
6
6
  describe '#on_workitem' do
7
7
  it 'calls method then replies' do
8
- subject.should_receive(:call_method).ordered
9
- subject.should_receive(:reply).ordered
8
+ expect(subject).to receive(:call_method).ordered
9
+ expect(subject).to receive(:reply).ordered
10
10
  subject._on_workitem(workitem)
11
11
  end
12
12
 
13
13
  it 'saves the requested attribute to a workitem field' do
14
14
  workitem.fields['params']['and_save_as'] = 'entity_cheek_depth'
15
15
  subject._on_workitem(workitem)
16
- workitem.fields['entity_cheek_depth'].should == 'crazy deep'
16
+ expect(workitem.fields['entity_cheek_depth']).to eq('crazy deep')
17
17
  end
18
18
 
19
19
  it 'overwrites an existing workitem field value' do
20
20
  workitem.fields['entity_cheek_depth'] = '14'
21
21
  workitem.fields['params']['and_save_as'] = 'entity_cheek_depth'
22
22
  subject._on_workitem(workitem)
23
- workitem.fields['entity_cheek_depth'].should == 'crazy deep'
23
+ expect(workitem.fields['entity_cheek_depth']).to eq('crazy deep')
24
24
  end
25
25
 
26
26
  it 'calls the method even if no save_as to store the result' do
27
- subject.entity.should_receive(:cheek_depth)
27
+ expect(subject.entity).to receive(:cheek_depth)
28
28
  subject._on_workitem(workitem)
29
- workitem.fields['entity_cheek_depth'].should be_nil
29
+ expect(workitem.fields['entity_cheek_depth']).to be_nil
30
30
  end
31
31
 
32
32
  it 'passes arguments to method' do
33
33
  workitem.fields['params']['arguments'] = [1, 3, ['apple', 'fish']]
34
34
  workitem.fields['params']['and_save_as'] = 'entity_cheek_depth'
35
- subject.entity.should_receive(:cheek_depth).with(1, 3, ['apple', 'fish']).and_return('what')
35
+ expect(subject.entity).to receive(:cheek_depth).with(1, 3, ['apple', 'fish']).and_return('what')
36
36
  subject._on_workitem(workitem)
37
- workitem.fields['entity_cheek_depth'].should == 'what'
37
+ expect(workitem.fields['entity_cheek_depth']).to eq('what')
38
38
  end
39
39
 
40
40
  it 'can accept "with" for arguments' do
41
41
  workitem.fields['params']['with'] = { :regular => 'joes' }
42
- subject.entity.should_receive(:cheek_depth).with({ :regular => 'joes' })
42
+ expect(subject.entity).to receive(:cheek_depth).with({ :regular => 'joes' })
43
43
  subject._on_workitem(workitem)
44
44
  end
45
45
 
46
46
  it 'can use "for" param for method' do
47
47
  workitem.fields['params'] = { 'for' => 'grass_seed', 'and_save_as' => 'how_tasty' }
48
- entity.should_receive(:grass_seed).and_return('tasty-o')
48
+ expect(entity).to receive(:grass_seed).and_return('tasty-o')
49
49
  subject._on_workitem(workitem)
50
- workitem.fields['how_tasty'].should == 'tasty-o'
50
+ expect(workitem.fields['how_tasty']).to eq('tasty-o')
51
51
  end
52
52
 
53
53
  it 'can use "to" param for method' do
54
54
  workitem.fields['params'] = { 'to' => 'chew_things' }
55
- entity.should_receive(:chew_things).and_return(nil)
55
+ expect(entity).to receive(:chew_things).and_return(nil)
56
56
  subject._on_workitem(workitem)
57
- workitem.fields['who_cares'].should be_nil
57
+ expect(workitem.fields['who_cares']).to be_nil
58
58
  end
59
59
 
60
60
  it 'defaults to "method" when multiple options exist' do
61
61
  workitem.fields['params'] = { 'method' => 'really_do_this', 'to' => 'not_this', 'for' => 'definitely_not_this' }
62
- entity.should_receive(:really_do_this)
62
+ expect(entity).to receive(:really_do_this)
63
63
  subject._on_workitem(workitem)
64
64
  end
65
65
 
66
66
  it 'defaults to "to" when both "to" and "for"' do
67
67
  workitem.fields['params'] = { 'to' => 'please_call_me', 'for' => 'call_me_maybe' }
68
- entity.should_receive(:please_call_me)
68
+ expect(entity).to receive(:please_call_me)
69
69
  subject._on_workitem(workitem)
70
70
  end
71
71
  end
72
72
 
73
73
  describe '#call_method' do
74
74
  it 'calls the requested method on the entity' do
75
- subject.call_method('cheek_depth').should == 'crazy deep'
75
+ expect(subject.call_method('cheek_depth')).to eq('crazy deep')
76
76
  end
77
77
 
78
78
  it 'saves the result if given a target' do
79
79
  subject.workitem = workitem
80
80
  subject.call_method('cheek_depth', :save_as => 'entity_cheek_depth')
81
- workitem.fields['entity_cheek_depth'].should == 'crazy deep'
81
+ expect(workitem.fields['entity_cheek_depth']).to eq('crazy deep')
82
82
  end
83
83
 
84
84
  it 'raises an exception if no method on entity' do
85
- subject.stub(:entity).and_return('just an unassuming little string!')
86
- expect {
85
+ allow(subject).to receive(:entity).and_return('just an unassuming little string!')
86
+ expect {
87
87
  subject.call_method('eat_television')
88
88
  }.to raise_error(NoMethodError)
89
89
  end
@@ -6,9 +6,9 @@ describe Bumbleworks::ErrorDispatcher do
6
6
 
7
7
  it 'calls all error handlers passing in workitem' do
8
8
  Bumbleworks.error_handlers = error_handlers
9
- error_handlers[0].should_receive(:new).ordered.with(workitem).and_return(instances[0])
10
- error_handlers[1].should_receive(:new).ordered.with(workitem).and_return(instances[1])
11
- subject.stub(:reply => nil, :workitem => workitem)
9
+ expect(error_handlers[0]).to receive(:new).ordered.with(workitem).and_return(instances[0])
10
+ expect(error_handlers[1]).to receive(:new).ordered.with(workitem).and_return(instances[1])
11
+ allow(subject).to receive_messages(:reply => nil, :workitem => workitem)
12
12
  subject.on_workitem
13
13
  end
14
14
  end
@@ -10,7 +10,7 @@ describe Bumbleworks::LocalParticipant do
10
10
  }
11
11
 
12
12
  it 'includes Ruote::LocalParticipant' do
13
- described_class.included_modules.should include(Ruote::LocalParticipant)
13
+ expect(described_class.included_modules).to include(Ruote::LocalParticipant)
14
14
  end
15
15
 
16
16
  it_behaves_like "an entity holder" do
@@ -5,9 +5,9 @@ describe Bumbleworks::ParticipantRegistration do
5
5
 
6
6
  describe '.autoload_all' do
7
7
  it 'autoloads all participants in directory' do
8
- Object.should_receive(:autoload).with(:HoneyParticipant,
8
+ expect(Object).to receive(:autoload).with(:HoneyParticipant,
9
9
  File.join(Bumbleworks.root, 'participants', 'honey_participant.rb'))
10
- Object.should_receive(:autoload).with(:MolassesParticipant,
10
+ expect(Object).to receive(:autoload).with(:MolassesParticipant,
11
11
  File.join(Bumbleworks.root, 'participants', 'molasses_participant.rb'))
12
12
  described_class.autoload_all
13
13
  end
@@ -27,13 +27,13 @@ describe Bumbleworks::ParticipantRegistration do
27
27
 
28
28
  describe '.register!' do
29
29
  it 'loads registration file' do
30
- Kernel.should_receive(:load).with(File.join(Bumbleworks.root, 'participants.rb'))
30
+ expect(Kernel).to receive(:load).with(File.join(Bumbleworks.root, 'participants.rb'))
31
31
  described_class.register!
32
32
  end
33
33
 
34
34
  it 'registers default participants if using default path and file does not exist' do
35
35
  Bumbleworks.root = File.join(fixtures_path, 'apps', 'minimal')
36
- Bumbleworks.should_receive(:register_default_participants)
36
+ expect(Bumbleworks).to receive(:register_default_participants)
37
37
  described_class.register!
38
38
  end
39
39
 
@@ -15,6 +15,19 @@ describe Bumbleworks::Process::ErrorRecord do
15
15
  @error = @process.errors.first
16
16
  end
17
17
 
18
+ describe '#replay' do
19
+ it 'replays the process at the error' do
20
+ expect(Bumbleworks.dashboard).to receive(:replay_at_error).with(@error.process_error)
21
+ @error.replay
22
+ end
23
+ end
24
+
25
+ describe '#workitem' do
26
+ it 'returns the workitem where the error occurred' do
27
+ expect(@error.workitem).to eq(@error.process_error.workitem)
28
+ end
29
+ end
30
+
18
31
  describe '#error_class_name' do
19
32
  it 'returns the class name of the recorded error (as a string)' do
20
33
  expect(@error.error_class_name).to eq 'NaughtyParticipant::StupidError'
@@ -7,25 +7,25 @@ describe Bumbleworks::ProcessDefinition do
7
7
 
8
8
  it "can be constructed with name and definition" do
9
9
  pdef = described_class.new(:name => 'zach', :definition => 'orbo')
10
- pdef.name.should == 'zach'
11
- pdef.definition.should == 'orbo'
10
+ expect(pdef.name).to eq('zach')
11
+ expect(pdef.definition).to eq('orbo')
12
12
  end
13
13
 
14
14
  it "can be constructed with name and tree" do
15
15
  pdef = described_class.new(:name => 'zach', :tree => ["define", {"your" => "face"}])
16
- pdef.name.should == 'zach'
17
- pdef.tree.should == ["define", {"your" => "face"}]
16
+ expect(pdef.name).to eq('zach')
17
+ expect(pdef.tree).to eq(["define", {"your" => "face"}])
18
18
  end
19
19
 
20
20
  describe '#build_tree!' do
21
21
  it "converts Bumbleworks definition to Ruote tree" do
22
22
  pdef = described_class.new(:name => 'monkeys', :definition => valid_definition)
23
- pdef.build_tree!.should == [
23
+ expect(pdef.build_tree!).to eq([
24
24
  "define", {"name" => "monkeys"},
25
25
  [
26
26
  ["chocolate_covered_skis", {"are" => "awesome"}, []]
27
27
  ]
28
- ]
28
+ ])
29
29
  end
30
30
 
31
31
  it "raises error if name in definition does not match" do
@@ -39,12 +39,12 @@ describe Bumbleworks::ProcessDefinition do
39
39
  it "adds name to tree when not specified in definition" do
40
40
  unnamed_def = valid_definition.gsub(/ 'monkeys'/, '')
41
41
  pdef = described_class.new(:name => 'spit_salad', :definition => unnamed_def)
42
- pdef.build_tree!.should == [
42
+ expect(pdef.build_tree!).to eq([
43
43
  "define", {"name" => "spit_salad"},
44
44
  [
45
45
  ["chocolate_covered_skis", {"are" => "awesome"}, []]
46
46
  ]
47
- ]
47
+ ])
48
48
  end
49
49
  end
50
50
 
@@ -72,7 +72,7 @@ describe Bumbleworks::ProcessDefinition do
72
72
  describe "#save!" do
73
73
  it "validates" do
74
74
  pdef = described_class.new
75
- pdef.should_receive(:validate!)
75
+ expect(pdef).to receive(:validate!)
76
76
  pdef.save!
77
77
  end
78
78
 
@@ -85,16 +85,18 @@ describe Bumbleworks::ProcessDefinition do
85
85
  it "registers the process definition with the dashboard" do
86
86
  pdef = described_class.new(:name => 'monkeys', :definition => valid_definition)
87
87
  pdef.save!
88
- Bumbleworks.dashboard.variables['monkeys'].should ==
88
+ expect(Bumbleworks.dashboard.variables['monkeys']).to eq(
89
89
  pdef.build_tree!
90
+ )
90
91
  end
91
92
 
92
93
  it "overwrites existing variable with new definition" do
93
94
  Bumbleworks.dashboard.variables['monkeys'] = 'A miraculous ingredient'
94
95
  pdef = described_class.new(:name => 'monkeys', :definition => valid_definition)
95
96
  pdef.save!
96
- Bumbleworks.dashboard.variables['monkeys'].should ==
97
+ expect(Bumbleworks.dashboard.variables['monkeys']).to eq(
97
98
  pdef.build_tree!
99
+ )
98
100
  end
99
101
  end
100
102
 
@@ -102,24 +104,24 @@ describe Bumbleworks::ProcessDefinition do
102
104
  it "returns an instance with a previously registered definition" do
103
105
  Bumbleworks.dashboard.variables['foo'] = 'go to the bar'
104
106
  pdef = described_class.find_by_name('foo')
105
- pdef.tree.should == 'go to the bar'
107
+ expect(pdef.tree).to eq('go to the bar')
106
108
  end
107
109
 
108
110
  it "raises an error if registered definition can't be found by given name" do
109
- lambda { described_class.find_by_name('nerf') }.should raise_error(described_class::NotFound)
111
+ expect { described_class.find_by_name('nerf') }.to raise_error(described_class::NotFound)
110
112
  end
111
113
  end
112
114
 
113
115
  describe "#load_definition_from_file" do
114
116
  it "raises an error if given file can't be found" do
115
117
  pdef = described_class.new(:name => 'whatever')
116
- lambda { pdef.load_definition_from_file('nerf') }.should raise_error(described_class::FileNotFound)
118
+ expect { pdef.load_definition_from_file('nerf') }.to raise_error(described_class::FileNotFound)
117
119
  end
118
120
 
119
121
  it "sets #definition to the parsed result of the file, if found" do
120
122
  pdef = described_class.new(:name => 'test_process')
121
123
  pdef.load_definition_from_file definition_path('test_process')
122
- pdef.definition.should == File.read(definition_path('test_process'))
124
+ expect(pdef.definition).to eq(File.read(definition_path('test_process')))
123
125
  end
124
126
  end
125
127
 
@@ -133,7 +135,7 @@ describe Bumbleworks::ProcessDefinition do
133
135
  end
134
136
 
135
137
  it 'raises error if duplicate filenames are encountered' do
136
- Bumbleworks::Support.stub(:all_files).and_return({
138
+ allow(Bumbleworks::Support).to receive(:all_files).and_return({
137
139
  'Rhubarb Derailleur' => 'popular_side_dish',
138
140
  'Cantonese Phrasebook' => 'popular_side_dish',
139
141
  'Beans' => 'unpopular_side_dish'
@@ -147,32 +149,35 @@ describe Bumbleworks::ProcessDefinition do
147
149
  Bumbleworks.dashboard.variables['keep_me'] = 'top_secret_cat_pics'
148
150
  # stubbing here so we can explicitly set an order which will
149
151
  # ensure we're testing rollback
150
- Bumbleworks::Support.stub(:all_files).and_return({
152
+ allow(Bumbleworks::Support).to receive(:all_files).and_return({
151
153
  definition_path('test_process') => 'test_process',
152
154
  definition_path('a_list_of_jams') => 'a_list_of_jams'
153
155
  })
154
156
  expect {
155
157
  described_class.create_all_from_directory!(definitions_path)
156
158
  }.to raise_error
157
- Bumbleworks.dashboard.variables['test_process'].should be_nil
158
- Bumbleworks.dashboard.variables['keep_me'].should == 'top_secret_cat_pics'
159
+ expect(Bumbleworks.dashboard.variables['test_process']).to be_nil
160
+ expect(Bumbleworks.dashboard.variables['keep_me']).to eq('top_secret_cat_pics')
159
161
  end
160
162
 
161
163
  it 'skips invalid files and loads all valid definitions when option specified' do
162
164
  described_class.create_all_from_directory!(definitions_path, :skip_invalid => true)
163
- Bumbleworks.dashboard.variables['test_process'].should ==
165
+ expect(Bumbleworks.dashboard.variables['test_process']).to eq(
164
166
  ["define", { "name" => "test_process" }, [["nothing", {}, []]]]
165
- Bumbleworks.dashboard.variables['test_nested_process'].should ==
167
+ )
168
+ expect(Bumbleworks.dashboard.variables['test_nested_process']).to eq(
166
169
  ["define", { "name" => "test_nested_process" }, [["nothing_nested", {}, []]]]
167
- Bumbleworks.dashboard.variables['a_list_of_jams'].should be_nil
170
+ )
171
+ expect(Bumbleworks.dashboard.variables['a_list_of_jams']).to be_nil
168
172
  end
169
173
  end
170
174
 
171
175
  describe '.create!' do
172
176
  it 'builds and saves a new instance' do
173
177
  pdef = described_class.create!(:name => 'monkeys', :definition => valid_definition)
174
- Bumbleworks.dashboard.variables['monkeys'].should ==
178
+ expect(Bumbleworks.dashboard.variables['monkeys']).to eq(
175
179
  pdef.build_tree!
180
+ )
176
181
  end
177
182
  end
178
183
 
@@ -181,8 +186,9 @@ describe Bumbleworks::ProcessDefinition do
181
186
  definition = described_class.define 'nammikins' do
182
187
  treefles
183
188
  end
184
- Bumbleworks.dashboard.variables['nammikins'].should ==
189
+ expect(Bumbleworks.dashboard.variables['nammikins']).to eq(
185
190
  ["define", {"name" => "nammikins"}, [["treefles", {}, []]]]
191
+ )
186
192
  end
187
193
  end
188
194
  end