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.
- checksums.yaml +7 -0
 - data/.rspec +1 -1
 - data/.ruby-version +1 -1
 - data/bumbleworks.gemspec +2 -2
 - data/lib/bumbleworks.rb +1 -0
 - data/lib/bumbleworks/expression.rb +12 -1
 - data/lib/bumbleworks/process.rb +10 -0
 - data/lib/bumbleworks/process/error_record.rb +14 -0
 - data/lib/bumbleworks/schedule.rb +58 -0
 - data/lib/bumbleworks/task.rb +2 -1
 - data/lib/bumbleworks/task/finder.rb +4 -0
 - data/lib/bumbleworks/version.rb +1 -1
 - data/lib/bumbleworks/workitem.rb +4 -0
 - data/spec/fixtures/schedules.rb +40 -0
 - data/spec/integration/entity_spec.rb +7 -7
 - data/spec/integration/example_configurations_spec.rb +5 -5
 - data/spec/integration/history_storage_spec.rb +9 -9
 - data/spec/integration/sample_application_spec.rb +15 -15
 - data/spec/lib/bumbleworks/configuration_spec.rb +52 -52
 - data/spec/lib/bumbleworks/entity_spec.rb +66 -68
 - data/spec/lib/bumbleworks/error_handler_spec.rb +1 -1
 - data/spec/lib/bumbleworks/error_logger_spec.rb +5 -5
 - data/spec/lib/bumbleworks/expression_spec.rb +34 -12
 - data/spec/lib/bumbleworks/hash_storage_spec.rb +2 -2
 - data/spec/lib/bumbleworks/participant/base_spec.rb +1 -1
 - data/spec/lib/bumbleworks/participant/entity_interactor_spec.rb +20 -20
 - data/spec/lib/bumbleworks/participant/error_dispatcher_spec.rb +3 -3
 - data/spec/lib/bumbleworks/participant/local_participant_spec.rb +1 -1
 - data/spec/lib/bumbleworks/participant_registration_spec.rb +4 -4
 - data/spec/lib/bumbleworks/process/error_record_spec.rb +13 -0
 - data/spec/lib/bumbleworks/process_definition_spec.rb +30 -24
 - data/spec/lib/bumbleworks/process_spec.rb +86 -54
 - data/spec/lib/bumbleworks/ruote/exp/broadcast_event_expression_spec.rb +2 -2
 - data/spec/lib/bumbleworks/ruote/exp/wait_for_event_expression_spec.rb +4 -4
 - data/spec/lib/bumbleworks/ruote_spec.rb +73 -71
 - data/spec/lib/bumbleworks/schedule_spec.rb +124 -0
 - data/spec/lib/bumbleworks/simple_logger_spec.rb +8 -8
 - data/spec/lib/bumbleworks/storage_adapter_spec.rb +16 -16
 - data/spec/lib/bumbleworks/support_spec.rb +23 -19
 - data/spec/lib/bumbleworks/task/finder_spec.rb +46 -46
 - data/spec/lib/bumbleworks/task_spec.rb +188 -167
 - data/spec/lib/bumbleworks/tracker_spec.rb +41 -42
 - data/spec/lib/bumbleworks/tree_builder_spec.rb +9 -7
 - data/spec/lib/bumbleworks/user_spec.rb +35 -35
 - data/spec/lib/bumbleworks/workitem_entity_storage_spec.rb +5 -5
 - data/spec/lib/bumbleworks/workitem_spec.rb +28 -17
 - data/spec/lib/bumbleworks_spec.rb +57 -51
 - data/spec/spec_helper.rb +0 -1
 - data/spec/support/shared_examples.rb +3 -3
 - metadata +35 -54
 
| 
         @@ -11,7 +11,7 @@ describe Bumbleworks::Configuration do 
     | 
|
| 
       11 
11 
     | 
    
         | 
| 
       12 
12 
     | 
    
         
             
                it 'returns folder set by user' do
         
     | 
| 
       13 
13 
     | 
    
         
             
                  configuration.root = '/what/about/that'
         
     | 
| 
       14 
     | 
    
         
            -
                  configuration.root. 
     | 
| 
      
 14 
     | 
    
         
            +
                  expect(configuration.root).to eq('/what/about/that')
         
     | 
| 
       15 
15 
     | 
    
         
             
                end
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
17 
     | 
    
         
             
                it 'uses Rails.root if Rails is defined' do
         
     | 
| 
         @@ -21,7 +21,7 @@ describe Bumbleworks::Configuration do 
     | 
|
| 
       21 
21 
     | 
    
         
             
                    end
         
     | 
| 
       22 
22 
     | 
    
         
             
                  end
         
     | 
| 
       23 
23 
     | 
    
         | 
| 
       24 
     | 
    
         
            -
                  configuration.root. 
     | 
| 
      
 24 
     | 
    
         
            +
                  expect(configuration.root).to eq('/Rails/Root/lib/bumbleworks')
         
     | 
| 
       25 
25 
     | 
    
         
             
                  Object.send(:remove_const, :Rails)
         
     | 
| 
       26 
26 
     | 
    
         
             
                end
         
     | 
| 
       27 
27 
     | 
    
         | 
| 
         @@ -32,7 +32,7 @@ describe Bumbleworks::Configuration do 
     | 
|
| 
       32 
32 
     | 
    
         
             
                    end
         
     | 
| 
       33 
33 
     | 
    
         
             
                  end
         
     | 
| 
       34 
34 
     | 
    
         | 
| 
       35 
     | 
    
         
            -
                  configuration.root. 
     | 
| 
      
 35 
     | 
    
         
            +
                  expect(configuration.root).to eq('/Padrino/Root/lib/bumbleworks')
         
     | 
| 
       36 
36 
     | 
    
         
             
                  Object.send(:remove_const, :Padrino)
         
     | 
| 
       37 
37 
     | 
    
         
             
                end
         
     | 
| 
       38 
38 
     | 
    
         | 
| 
         @@ -45,7 +45,7 @@ describe Bumbleworks::Configuration do 
     | 
|
| 
       45 
45 
     | 
    
         
             
                    end
         
     | 
| 
       46 
46 
     | 
    
         
             
                  end
         
     | 
| 
       47 
47 
     | 
    
         | 
| 
       48 
     | 
    
         
            -
                  configuration.root. 
     | 
| 
      
 48 
     | 
    
         
            +
                  expect(configuration.root).to eq('/Sinatra/Root/lib/bumbleworks')
         
     | 
| 
       49 
49 
     | 
    
         
             
                  Object.send(:remove_const, :Sinatra)
         
     | 
| 
       50 
50 
     | 
    
         
             
                end
         
     | 
| 
       51 
51 
     | 
    
         | 
| 
         @@ -56,7 +56,7 @@ describe Bumbleworks::Configuration do 
     | 
|
| 
       56 
56 
     | 
    
         
             
                    end
         
     | 
| 
       57 
57 
     | 
    
         
             
                  end
         
     | 
| 
       58 
58 
     | 
    
         | 
| 
       59 
     | 
    
         
            -
                  configuration.root. 
     | 
| 
      
 59 
     | 
    
         
            +
                  expect(configuration.root).to eq('/Rory/Root/lib/bumbleworks')
         
     | 
| 
       60 
60 
     | 
    
         
             
                  Object.send(:remove_const, :Rory)
         
     | 
| 
       61 
61 
     | 
    
         
             
                end
         
     | 
| 
       62 
62 
     | 
    
         | 
| 
         @@ -74,27 +74,27 @@ describe Bumbleworks::Configuration do 
     | 
|
| 
       74 
74 
     | 
    
         | 
| 
       75 
75 
     | 
    
         
             
              describe "#definitions_directory" do
         
     | 
| 
       76 
76 
     | 
    
         
             
                it 'returns the folder which was set by the client app' do
         
     | 
| 
       77 
     | 
    
         
            -
                  File. 
     | 
| 
      
 77 
     | 
    
         
            +
                  allow(File).to receive(:directory?).with('/dog/ate/my/homework').and_return(true)
         
     | 
| 
       78 
78 
     | 
    
         
             
                  configuration.definitions_directory = '/dog/ate/my/homework'
         
     | 
| 
       79 
     | 
    
         
            -
                  configuration.definitions_directory. 
     | 
| 
      
 79 
     | 
    
         
            +
                  expect(configuration.definitions_directory).to eq('/dog/ate/my/homework')
         
     | 
| 
       80 
80 
     | 
    
         
             
                end
         
     | 
| 
       81 
81 
     | 
    
         | 
| 
       82 
82 
     | 
    
         
             
                it 'returns the default folder if not set by client app' do
         
     | 
| 
       83 
     | 
    
         
            -
                  File. 
     | 
| 
      
 83 
     | 
    
         
            +
                  allow(File).to receive_messages(:directory? => true)
         
     | 
| 
       84 
84 
     | 
    
         
             
                  configuration.root = '/Root'
         
     | 
| 
       85 
     | 
    
         
            -
                  configuration.definitions_directory. 
     | 
| 
      
 85 
     | 
    
         
            +
                  expect(configuration.definitions_directory).to eq('/Root/process_definitions')
         
     | 
| 
       86 
86 
     | 
    
         
             
                end
         
     | 
| 
       87 
87 
     | 
    
         | 
| 
       88 
88 
     | 
    
         
             
                it 'returns the second default folder if first does not exist' do
         
     | 
| 
       89 
     | 
    
         
            -
                  File. 
     | 
| 
       90 
     | 
    
         
            -
                  File. 
     | 
| 
      
 89 
     | 
    
         
            +
                  allow(File).to receive(:directory?).with('/Root/process_definitions').and_return(false)
         
     | 
| 
      
 90 
     | 
    
         
            +
                  allow(File).to receive(:directory?).with('/Root/processes').and_return(true)
         
     | 
| 
       91 
91 
     | 
    
         
             
                  configuration.root = '/Root'
         
     | 
| 
       92 
     | 
    
         
            -
                  configuration.definitions_directory. 
     | 
| 
      
 92 
     | 
    
         
            +
                  expect(configuration.definitions_directory).to eq('/Root/processes')
         
     | 
| 
       93 
93 
     | 
    
         
             
                end
         
     | 
| 
       94 
94 
     | 
    
         | 
| 
       95 
95 
     | 
    
         
             
                it 'returns nil if default folder not found' do
         
     | 
| 
       96 
96 
     | 
    
         
             
                  configuration.root = '/Root'
         
     | 
| 
       97 
     | 
    
         
            -
                  configuration.definitions_directory. 
     | 
| 
      
 97 
     | 
    
         
            +
                  expect(configuration.definitions_directory).to be_nil
         
     | 
| 
       98 
98 
     | 
    
         
             
                end
         
     | 
| 
       99 
99 
     | 
    
         | 
| 
       100 
100 
     | 
    
         
             
                it 'raises error if specific folder not found' do
         
     | 
| 
         @@ -110,20 +110,20 @@ describe Bumbleworks::Configuration do 
     | 
|
| 
       110 
110 
     | 
    
         | 
| 
       111 
111 
     | 
    
         
             
              describe "#participants_directory" do
         
     | 
| 
       112 
112 
     | 
    
         
             
                it 'returns the folder which was set by the client app' do
         
     | 
| 
       113 
     | 
    
         
            -
                  File. 
     | 
| 
      
 113 
     | 
    
         
            +
                  allow(File).to receive(:directory?).with('/dog/ate/my/homework').and_return(true)
         
     | 
| 
       114 
114 
     | 
    
         
             
                  configuration.participants_directory = '/dog/ate/my/homework'
         
     | 
| 
       115 
     | 
    
         
            -
                  configuration.participants_directory. 
     | 
| 
      
 115 
     | 
    
         
            +
                  expect(configuration.participants_directory).to eq('/dog/ate/my/homework')
         
     | 
| 
       116 
116 
     | 
    
         
             
                end
         
     | 
| 
       117 
117 
     | 
    
         | 
| 
       118 
118 
     | 
    
         
             
                it 'returns the default folder if not set by client app' do
         
     | 
| 
       119 
     | 
    
         
            -
                  File. 
     | 
| 
      
 119 
     | 
    
         
            +
                  allow(File).to receive(:directory?).with('/Root/participants').and_return(true)
         
     | 
| 
       120 
120 
     | 
    
         
             
                  configuration.root = '/Root'
         
     | 
| 
       121 
     | 
    
         
            -
                  configuration.participants_directory. 
     | 
| 
      
 121 
     | 
    
         
            +
                  expect(configuration.participants_directory).to eq('/Root/participants')
         
     | 
| 
       122 
122 
     | 
    
         
             
                end
         
     | 
| 
       123 
123 
     | 
    
         | 
| 
       124 
124 
     | 
    
         
             
                it 'returns nil if default folder not found' do
         
     | 
| 
       125 
125 
     | 
    
         
             
                  configuration.root = '/Root'
         
     | 
| 
       126 
     | 
    
         
            -
                  configuration.participants_directory. 
     | 
| 
      
 126 
     | 
    
         
            +
                  expect(configuration.participants_directory).to be_nil
         
     | 
| 
       127 
127 
     | 
    
         
             
                end
         
     | 
| 
       128 
128 
     | 
    
         | 
| 
       129 
129 
     | 
    
         
             
                it 'raises error if specific folder not found' do
         
     | 
| 
         @@ -139,20 +139,20 @@ describe Bumbleworks::Configuration do 
     | 
|
| 
       139 
139 
     | 
    
         | 
| 
       140 
140 
     | 
    
         
             
              describe "#tasks_directory" do
         
     | 
| 
       141 
141 
     | 
    
         
             
                it 'returns the folder which was set by the client app' do
         
     | 
| 
       142 
     | 
    
         
            -
                  File. 
     | 
| 
      
 142 
     | 
    
         
            +
                  allow(File).to receive(:directory?).with('/dog/ate/my/homework').and_return(true)
         
     | 
| 
       143 
143 
     | 
    
         
             
                  configuration.tasks_directory = '/dog/ate/my/homework'
         
     | 
| 
       144 
     | 
    
         
            -
                  configuration.tasks_directory. 
     | 
| 
      
 144 
     | 
    
         
            +
                  expect(configuration.tasks_directory).to eq('/dog/ate/my/homework')
         
     | 
| 
       145 
145 
     | 
    
         
             
                end
         
     | 
| 
       146 
146 
     | 
    
         | 
| 
       147 
147 
     | 
    
         
             
                it 'returns the default folder if not set by client app' do
         
     | 
| 
       148 
     | 
    
         
            -
                  File. 
     | 
| 
      
 148 
     | 
    
         
            +
                  allow(File).to receive(:directory?).with('/Root/tasks').and_return(true)
         
     | 
| 
       149 
149 
     | 
    
         
             
                  configuration.root = '/Root'
         
     | 
| 
       150 
     | 
    
         
            -
                  configuration.tasks_directory. 
     | 
| 
      
 150 
     | 
    
         
            +
                  expect(configuration.tasks_directory).to eq('/Root/tasks')
         
     | 
| 
       151 
151 
     | 
    
         
             
                end
         
     | 
| 
       152 
152 
     | 
    
         | 
| 
       153 
153 
     | 
    
         
             
                it 'returns nil if default folder not found' do
         
     | 
| 
       154 
154 
     | 
    
         
             
                  configuration.root = '/Root'
         
     | 
| 
       155 
     | 
    
         
            -
                  configuration.tasks_directory. 
     | 
| 
      
 155 
     | 
    
         
            +
                  expect(configuration.tasks_directory).to be_nil
         
     | 
| 
       156 
156 
     | 
    
         
             
                end
         
     | 
| 
       157 
157 
     | 
    
         | 
| 
       158 
158 
     | 
    
         
             
                it 'raises error if specific folder not found' do
         
     | 
| 
         @@ -168,20 +168,20 @@ describe Bumbleworks::Configuration do 
     | 
|
| 
       168 
168 
     | 
    
         | 
| 
       169 
169 
     | 
    
         
             
              describe "#participant_registration_file" do
         
     | 
| 
       170 
170 
     | 
    
         
             
                it 'returns the path which was set by the client app' do
         
     | 
| 
       171 
     | 
    
         
            -
                  File. 
     | 
| 
      
 171 
     | 
    
         
            +
                  allow(File).to receive(:file?).with('/can/i/get/a/rooster.rb').and_return(true)
         
     | 
| 
       172 
172 
     | 
    
         
             
                  configuration.participant_registration_file = '/can/i/get/a/rooster.rb'
         
     | 
| 
       173 
     | 
    
         
            -
                  configuration.participant_registration_file. 
     | 
| 
      
 173 
     | 
    
         
            +
                  expect(configuration.participant_registration_file).to eq('/can/i/get/a/rooster.rb')
         
     | 
| 
       174 
174 
     | 
    
         
             
                end
         
     | 
| 
       175 
175 
     | 
    
         | 
| 
       176 
176 
     | 
    
         
             
                it 'returns the default folder if not set by client app' do
         
     | 
| 
       177 
     | 
    
         
            -
                  File. 
     | 
| 
      
 177 
     | 
    
         
            +
                  allow(File).to receive(:file?).with('/Root/participants.rb').and_return(true)
         
     | 
| 
       178 
178 
     | 
    
         
             
                  configuration.root = '/Root'
         
     | 
| 
       179 
     | 
    
         
            -
                  configuration.participant_registration_file. 
     | 
| 
      
 179 
     | 
    
         
            +
                  expect(configuration.participant_registration_file).to eq('/Root/participants.rb')
         
     | 
| 
       180 
180 
     | 
    
         
             
                end
         
     | 
| 
       181 
181 
     | 
    
         | 
| 
       182 
182 
     | 
    
         
             
                it 'returns nil if default path not found' do
         
     | 
| 
       183 
183 
     | 
    
         
             
                  configuration.root = '/Root'
         
     | 
| 
       184 
     | 
    
         
            -
                  configuration.participant_registration_file. 
     | 
| 
      
 184 
     | 
    
         
            +
                  expect(configuration.participant_registration_file).to be_nil
         
     | 
| 
       185 
185 
     | 
    
         
             
                end
         
     | 
| 
       186 
186 
     | 
    
         | 
| 
       187 
187 
     | 
    
         
             
                it 'raises error if specific path not found' do
         
     | 
| 
         @@ -198,35 +198,35 @@ describe Bumbleworks::Configuration do 
     | 
|
| 
       198 
198 
     | 
    
         
             
              describe '#logger' do
         
     | 
| 
       199 
199 
     | 
    
         
             
                it 'returns the registered logger' do
         
     | 
| 
       200 
200 
     | 
    
         
             
                  configuration.logger = :a_logger
         
     | 
| 
       201 
     | 
    
         
            -
                  configuration.logger. 
     | 
| 
      
 201 
     | 
    
         
            +
                  expect(configuration.logger).to eq(:a_logger)
         
     | 
| 
       202 
202 
     | 
    
         
             
                end
         
     | 
| 
       203 
203 
     | 
    
         | 
| 
       204 
204 
     | 
    
         
             
                it 'returns the default simple logger if no logger registered' do
         
     | 
| 
       205 
     | 
    
         
            -
                  configuration.logger. 
     | 
| 
      
 205 
     | 
    
         
            +
                  expect(configuration.logger).to eq(Bumbleworks::SimpleLogger)
         
     | 
| 
       206 
206 
     | 
    
         
             
                end
         
     | 
| 
       207 
207 
     | 
    
         
             
              end
         
     | 
| 
       208 
208 
     | 
    
         | 
| 
       209 
209 
     | 
    
         
             
              describe '#observers' do
         
     | 
| 
       210 
210 
     | 
    
         
             
                it 'is empty by default' do
         
     | 
| 
       211 
     | 
    
         
            -
                  configuration.observers. 
     | 
| 
      
 211 
     | 
    
         
            +
                  expect(configuration.observers).to be_empty
         
     | 
| 
       212 
212 
     | 
    
         
             
                end
         
     | 
| 
       213 
213 
     | 
    
         | 
| 
       214 
214 
     | 
    
         
             
                it 'returns the registered observers' do
         
     | 
| 
       215 
215 
     | 
    
         
             
                  configuration.observers = [:smash, :pumpkin]
         
     | 
| 
       216 
216 
     | 
    
         
             
                  configuration.observers << :rhubarb
         
     | 
| 
       217 
     | 
    
         
            -
                  configuration.observers. 
     | 
| 
      
 217 
     | 
    
         
            +
                  expect(configuration.observers).to eq([:smash, :pumpkin, :rhubarb])
         
     | 
| 
       218 
218 
     | 
    
         
             
                end
         
     | 
| 
       219 
219 
     | 
    
         
             
              end
         
     | 
| 
       220 
220 
     | 
    
         | 
| 
       221 
221 
     | 
    
         
             
              describe '#entity_classes' do
         
     | 
| 
       222 
222 
     | 
    
         
             
                it 'is empty by default' do
         
     | 
| 
       223 
     | 
    
         
            -
                  configuration.entity_classes. 
     | 
| 
      
 223 
     | 
    
         
            +
                  expect(configuration.entity_classes).to be_empty
         
     | 
| 
       224 
224 
     | 
    
         
             
                end
         
     | 
| 
       225 
225 
     | 
    
         | 
| 
       226 
226 
     | 
    
         
             
                it 'returns the registered entity classes' do
         
     | 
| 
       227 
227 
     | 
    
         
             
                  configuration.entity_classes = [:fumpin, :nuffin]
         
     | 
| 
       228 
228 
     | 
    
         
             
                  configuration.entity_classes << :summin
         
     | 
| 
       229 
     | 
    
         
            -
                  configuration.entity_classes. 
     | 
| 
      
 229 
     | 
    
         
            +
                  expect(configuration.entity_classes).to eq([:fumpin, :nuffin, :summin])
         
     | 
| 
       230 
230 
     | 
    
         
             
                end
         
     | 
| 
       231 
231 
     | 
    
         
             
              end
         
     | 
| 
       232 
232 
     | 
    
         | 
| 
         @@ -234,18 +234,18 @@ describe Bumbleworks::Configuration do 
     | 
|
| 
       234 
234 
     | 
    
         
             
                it 'can set storage directly' do
         
     | 
| 
       235 
235 
     | 
    
         
             
                  storage = double("Storage")
         
     | 
| 
       236 
236 
     | 
    
         
             
                  configuration.storage = storage
         
     | 
| 
       237 
     | 
    
         
            -
                  configuration.storage. 
     | 
| 
      
 237 
     | 
    
         
            +
                  expect(configuration.storage).to eq(storage)
         
     | 
| 
       238 
238 
     | 
    
         
             
                end
         
     | 
| 
       239 
239 
     | 
    
         
             
              end
         
     | 
| 
       240 
240 
     | 
    
         | 
| 
       241 
241 
     | 
    
         
             
              describe '#storage_options' do
         
     | 
| 
       242 
242 
     | 
    
         
             
                it 'defaults to empty hash' do
         
     | 
| 
       243 
     | 
    
         
            -
                  subject.storage_options. 
     | 
| 
      
 243 
     | 
    
         
            +
                  expect(subject.storage_options).to eq({})
         
     | 
| 
       244 
244 
     | 
    
         
             
                end
         
     | 
| 
       245 
245 
     | 
    
         | 
| 
       246 
246 
     | 
    
         
             
                it 'can be overridden' do
         
     | 
| 
       247 
247 
     | 
    
         
             
                  subject.storage_options = { :smooshie => 'wubbles' }
         
     | 
| 
       248 
     | 
    
         
            -
                  subject.storage_options. 
     | 
| 
      
 248 
     | 
    
         
            +
                  expect(subject.storage_options).to eq({ :smooshie => 'wubbles' })
         
     | 
| 
       249 
249 
     | 
    
         
             
                end
         
     | 
| 
       250 
250 
     | 
    
         
             
              end
         
     | 
| 
       251 
251 
     | 
    
         | 
| 
         @@ -254,19 +254,19 @@ describe Bumbleworks::Configuration do 
     | 
|
| 
       254 
254 
     | 
    
         
             
                  right_adapter = double('right', :use? => true)
         
     | 
| 
       255 
255 
     | 
    
         
             
                  wrong_adapter_1 = double('wrong1', :use? => false)
         
     | 
| 
       256 
256 
     | 
    
         
             
                  wrong_adapter_2 = double('wrong2', :use? => false)
         
     | 
| 
       257 
     | 
    
         
            -
                  subject. 
     | 
| 
       258 
     | 
    
         
            -
                  subject.storage_adapter. 
     | 
| 
      
 257 
     | 
    
         
            +
                  allow(subject).to receive_messages(:storage_adapters => [wrong_adapter_1, right_adapter, wrong_adapter_2])
         
     | 
| 
      
 258 
     | 
    
         
            +
                  expect(subject.storage_adapter).to eq(right_adapter)
         
     | 
| 
       259 
259 
     | 
    
         
             
                end
         
     | 
| 
       260 
260 
     | 
    
         | 
| 
       261 
261 
     | 
    
         
             
                it 'can be set storage directly' do
         
     | 
| 
       262 
262 
     | 
    
         
             
                  storage = double("Storage Adapter")
         
     | 
| 
       263 
263 
     | 
    
         
             
                  subject.storage_adapter = storage
         
     | 
| 
       264 
     | 
    
         
            -
                  subject.storage_adapter. 
     | 
| 
      
 264 
     | 
    
         
            +
                  expect(subject.storage_adapter).to eq(storage)
         
     | 
| 
       265 
265 
     | 
    
         
             
                end
         
     | 
| 
       266 
266 
     | 
    
         | 
| 
       267 
267 
     | 
    
         
             
                it 'raises UndefinedSetting if no matching storage adapter' do
         
     | 
| 
       268 
268 
     | 
    
         
             
                  wrong_adapter = double('wrong1', :use? => false, :display_name => 'Wrong')
         
     | 
| 
       269 
     | 
    
         
            -
                  subject. 
     | 
| 
      
 269 
     | 
    
         
            +
                  allow(subject).to receive_messages(:storage_adapters => [wrong_adapter])
         
     | 
| 
       270 
270 
     | 
    
         
             
                  expect {
         
     | 
| 
       271 
271 
     | 
    
         
             
                    subject.storage_adapter
         
     | 
| 
       272 
272 
     | 
    
         
             
                  }.to raise_error(Bumbleworks::UndefinedSetting,
         
     | 
| 
         @@ -284,12 +284,12 @@ describe Bumbleworks::Configuration do 
     | 
|
| 
       284 
284 
     | 
    
         
             
              describe '#add_storage_adapter' do
         
     | 
| 
       285 
285 
     | 
    
         
             
                it 'adds storage adapter to registered list' do
         
     | 
| 
       286 
286 
     | 
    
         
             
                  GoodForNothingStorage = double('fake_storage', :respond_to? => true)
         
     | 
| 
       287 
     | 
    
         
            -
                  configuration.storage_adapters. 
     | 
| 
      
 287 
     | 
    
         
            +
                  expect(configuration.storage_adapters).to be_empty
         
     | 
| 
       288 
288 
     | 
    
         
             
                  configuration.add_storage_adapter(GoodForNothingStorage)
         
     | 
| 
       289 
289 
     | 
    
         
             
                  configuration.add_storage_adapter(Bumbleworks::HashStorage)
         
     | 
| 
       290 
     | 
    
         
            -
                  configuration.storage_adapters. 
     | 
| 
      
 290 
     | 
    
         
            +
                  expect(configuration.storage_adapters).to match_array([
         
     | 
| 
       291 
291 
     | 
    
         
             
                    GoodForNothingStorage, Bumbleworks::HashStorage
         
     | 
| 
       292 
     | 
    
         
            -
                  ]
         
     | 
| 
      
 292 
     | 
    
         
            +
                  ])
         
     | 
| 
       293 
293 
     | 
    
         
             
                end
         
     | 
| 
       294 
294 
     | 
    
         | 
| 
       295 
295 
     | 
    
         
             
                it 'raises ArgumentError if object is not a storage adapter' do
         
     | 
| 
         @@ -307,41 +307,41 @@ describe Bumbleworks::Configuration do 
     | 
|
| 
       307 
307 
     | 
    
         
             
                end
         
     | 
| 
       308 
308 
     | 
    
         | 
| 
       309 
309 
     | 
    
         
             
                it 'resets #definitions_directory' do
         
     | 
| 
       310 
     | 
    
         
            -
                  File. 
     | 
| 
      
 310 
     | 
    
         
            +
                  allow(File).to receive_messages(:directory? => true)
         
     | 
| 
       311 
311 
     | 
    
         
             
                  configuration.definitions_directory = '/One/Two'
         
     | 
| 
       312 
     | 
    
         
            -
                  configuration.definitions_directory. 
     | 
| 
      
 312 
     | 
    
         
            +
                  expect(configuration.definitions_directory).to eq('/One/Two')
         
     | 
| 
       313 
313 
     | 
    
         
             
                  configuration.clear!
         
     | 
| 
       314 
314 
     | 
    
         | 
| 
       315 
315 
     | 
    
         
             
                  configuration.root = '/Root'
         
     | 
| 
       316 
     | 
    
         
            -
                  configuration.definitions_directory. 
     | 
| 
      
 316 
     | 
    
         
            +
                  expect(configuration.definitions_directory).to eq('/Root/process_definitions')
         
     | 
| 
       317 
317 
     | 
    
         
             
                end
         
     | 
| 
       318 
318 
     | 
    
         
             
              end
         
     | 
| 
       319 
319 
     | 
    
         | 
| 
       320 
320 
     | 
    
         
             
              describe '#error_handlers', dev:true do
         
     | 
| 
       321 
321 
     | 
    
         
             
                let(:super_handler) {double('error_handler')}
         
     | 
| 
       322 
322 
     | 
    
         
             
                it 'sets default error handler' do
         
     | 
| 
       323 
     | 
    
         
            -
                  configuration.error_handlers. 
     | 
| 
      
 323 
     | 
    
         
            +
                  expect(configuration.error_handlers).to eq([Bumbleworks::ErrorLogger])
         
     | 
| 
       324 
324 
     | 
    
         
             
                end
         
     | 
| 
       325 
325 
     | 
    
         | 
| 
       326 
326 
     | 
    
         
             
                it 'replaces default handler' do
         
     | 
| 
       327 
327 
     | 
    
         
             
                  configuration.error_handlers = [super_handler]
         
     | 
| 
       328 
     | 
    
         
            -
                  configuration.error_handlers. 
     | 
| 
      
 328 
     | 
    
         
            +
                  expect(configuration.error_handlers).to eq([super_handler])
         
     | 
| 
       329 
329 
     | 
    
         
             
                end
         
     | 
| 
       330 
330 
     | 
    
         | 
| 
       331 
331 
     | 
    
         
             
                it 'adds to default handler' do
         
     | 
| 
       332 
332 
     | 
    
         
             
                  configuration.error_handlers << super_handler
         
     | 
| 
       333 
     | 
    
         
            -
                  configuration.error_handlers. 
     | 
| 
      
 333 
     | 
    
         
            +
                  expect(configuration.error_handlers).to match_array([Bumbleworks::ErrorLogger, super_handler])
         
     | 
| 
       334 
334 
     | 
    
         
             
                end
         
     | 
| 
       335 
335 
     | 
    
         
             
              end
         
     | 
| 
       336 
336 
     | 
    
         | 
| 
       337 
337 
     | 
    
         
             
              describe '#store_history' do
         
     | 
| 
       338 
338 
     | 
    
         
             
                it 'defaults to true' do
         
     | 
| 
       339 
     | 
    
         
            -
                  subject.store_history. 
     | 
| 
      
 339 
     | 
    
         
            +
                  expect(subject.store_history).to be_truthy
         
     | 
| 
       340 
340 
     | 
    
         
             
                end
         
     | 
| 
       341 
341 
     | 
    
         | 
| 
       342 
342 
     | 
    
         
             
                it 'can be overridden' do
         
     | 
| 
       343 
343 
     | 
    
         
             
                  subject.store_history = false
         
     | 
| 
       344 
     | 
    
         
            -
                  subject.store_history. 
     | 
| 
      
 344 
     | 
    
         
            +
                  expect(subject.store_history).to be_falsy
         
     | 
| 
       345 
345 
     | 
    
         
             
                end
         
     | 
| 
       346 
346 
     | 
    
         
             
              end
         
     | 
| 
       347 
347 
     | 
    
         
             
            end
         
     | 
| 
         @@ -4,17 +4,17 @@ describe Bumbleworks::Entity do 
     | 
|
| 
       4 
4 
     | 
    
         
             
              describe '#identifier' do
         
     | 
| 
       5 
5 
     | 
    
         
             
                it 'returns id by default' do
         
     | 
| 
       6 
6 
     | 
    
         
             
                  entity = entity_class.new
         
     | 
| 
       7 
     | 
    
         
            -
                  entity. 
     | 
| 
       8 
     | 
    
         
            -
                  entity.identifier. 
     | 
| 
      
 7 
     | 
    
         
            +
                  allow(entity).to receive_messages(:id => 'berf')
         
     | 
| 
      
 8 
     | 
    
         
            +
                  expect(entity.identifier).to eq('berf')
         
     | 
| 
       9 
9 
     | 
    
         
             
                end
         
     | 
| 
       10 
10 
     | 
    
         
             
              end
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
       12 
12 
     | 
    
         
             
              describe '#to_s' do
         
     | 
| 
       13 
13 
     | 
    
         
             
                it 'returns string with titleized class name and identifier' do
         
     | 
| 
       14 
     | 
    
         
            -
                  entity_class. 
     | 
| 
      
 14 
     | 
    
         
            +
                  allow(entity_class).to receive_messages(:name => 'GiantAngryPlum')
         
     | 
| 
       15 
15 
     | 
    
         
             
                  entity = entity_class.new
         
     | 
| 
       16 
     | 
    
         
            -
                  entity. 
     | 
| 
       17 
     | 
    
         
            -
                  entity.to_s. 
     | 
| 
      
 16 
     | 
    
         
            +
                  allow(entity).to receive_messages(:identifier => 1490)
         
     | 
| 
      
 17 
     | 
    
         
            +
                  expect(entity.to_s).to eq('Giant Angry Plum 1490')
         
     | 
| 
       18 
18 
     | 
    
         
             
                end
         
     | 
| 
       19 
19 
     | 
    
         
             
              end
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
         @@ -28,15 +28,15 @@ describe Bumbleworks::Entity do 
     | 
|
| 
       28 
28 
     | 
    
         
             
                  entity = entity_class.new
         
     | 
| 
       29 
29 
     | 
    
         
             
                  entity.foof_pid = '1234'
         
     | 
| 
       30 
30 
     | 
    
         
             
                  entity.nook_pid = 'pickles'
         
     | 
| 
       31 
     | 
    
         
            -
                  entity.processes_by_name. 
     | 
| 
      
 31 
     | 
    
         
            +
                  expect(entity.processes_by_name).to eq({
         
     | 
| 
       32 
32 
     | 
    
         
             
                    :zoom => nil,
         
     | 
| 
       33 
33 
     | 
    
         
             
                    :foof => Bumbleworks::Process.new('1234'),
         
     | 
| 
       34 
34 
     | 
    
         
             
                    :nook => Bumbleworks::Process.new('pickles')
         
     | 
| 
       35 
     | 
    
         
            -
                  }
         
     | 
| 
      
 35 
     | 
    
         
            +
                  })
         
     | 
| 
       36 
36 
     | 
    
         
             
                end
         
     | 
| 
       37 
37 
     | 
    
         | 
| 
       38 
38 
     | 
    
         
             
                it 'returns empty hash if no processes' do
         
     | 
| 
       39 
     | 
    
         
            -
                  entity_class.new.processes_by_name. 
     | 
| 
      
 39 
     | 
    
         
            +
                  expect(entity_class.new.processes_by_name).to eq({})
         
     | 
| 
       40 
40 
     | 
    
         
             
                end
         
     | 
| 
       41 
41 
     | 
    
         
             
              end
         
     | 
| 
       42 
42 
     | 
    
         | 
| 
         @@ -49,39 +49,39 @@ describe Bumbleworks::Entity do 
     | 
|
| 
       49 
49 
     | 
    
         
             
                  entity = entity_class.new
         
     | 
| 
       50 
50 
     | 
    
         
             
                  entity.foof_pid = '1234'
         
     | 
| 
       51 
51 
     | 
    
         
             
                  entity.nook_pid = 'pickles'
         
     | 
| 
       52 
     | 
    
         
            -
                  entity.processes. 
     | 
| 
      
 52 
     | 
    
         
            +
                  expect(entity.processes).to match_array([
         
     | 
| 
       53 
53 
     | 
    
         
             
                    Bumbleworks::Process.new('1234'),
         
     | 
| 
       54 
54 
     | 
    
         
             
                    Bumbleworks::Process.new('pickles')
         
     | 
| 
       55 
     | 
    
         
            -
                  ]
         
     | 
| 
      
 55 
     | 
    
         
            +
                  ])
         
     | 
| 
       56 
56 
     | 
    
         
             
                end
         
     | 
| 
       57 
57 
     | 
    
         | 
| 
       58 
58 
     | 
    
         
             
                it 'returns empty array if no processes' do
         
     | 
| 
       59 
     | 
    
         
            -
                  entity_class.new.processes. 
     | 
| 
      
 59 
     | 
    
         
            +
                  expect(entity_class.new.processes).to eq([])
         
     | 
| 
       60 
60 
     | 
    
         
             
                end
         
     | 
| 
       61 
61 
     | 
    
         
             
              end
         
     | 
| 
       62 
62 
     | 
    
         | 
| 
       63 
63 
     | 
    
         
             
              describe '#cancel_all_processes!' do
         
     | 
| 
       64 
64 
     | 
    
         
             
                it 'cancels all processes with registered identifiers' do
         
     | 
| 
       65 
65 
     | 
    
         
             
                  entity = entity_class.new
         
     | 
| 
       66 
     | 
    
         
            -
                  entity. 
     | 
| 
      
 66 
     | 
    
         
            +
                  allow(entity).to receive_messages(:processes_by_name => {
         
     | 
| 
       67 
67 
     | 
    
         
             
                    :foof => bp1 = Bumbleworks::Process.new('1234'),
         
     | 
| 
       68 
68 
     | 
    
         
             
                    :nook => bp2 = Bumbleworks::Process.new('pickles')
         
     | 
| 
       69 
69 
     | 
    
         
             
                  })
         
     | 
| 
       70 
     | 
    
         
            -
                  bp1. 
     | 
| 
       71 
     | 
    
         
            -
                  bp2. 
     | 
| 
       72 
     | 
    
         
            -
                  entity. 
     | 
| 
       73 
     | 
    
         
            -
                  entity. 
     | 
| 
       74 
     | 
    
         
            -
                  entity. 
     | 
| 
      
 70 
     | 
    
         
            +
                  expect(bp1).to receive(:cancel!)
         
     | 
| 
      
 71 
     | 
    
         
            +
                  expect(bp2).to receive(:cancel!)
         
     | 
| 
      
 72 
     | 
    
         
            +
                  allow(entity).to receive(:attribute_for_process_name) { |name| :"#{name}_pid" }
         
     | 
| 
      
 73 
     | 
    
         
            +
                  expect(entity).to receive(:update).with(:foof_pid => nil)
         
     | 
| 
      
 74 
     | 
    
         
            +
                  expect(entity).to receive(:update).with(:nook_pid => nil)
         
     | 
| 
       75 
75 
     | 
    
         
             
                  entity.cancel_all_processes!
         
     | 
| 
       76 
76 
     | 
    
         
             
                end
         
     | 
| 
       77 
77 
     | 
    
         | 
| 
       78 
78 
     | 
    
         
             
                it 'does not clear identifiers if clear_identifiers option is false' do
         
     | 
| 
       79 
79 
     | 
    
         
             
                  entity = entity_class.new
         
     | 
| 
       80 
     | 
    
         
            -
                  entity. 
     | 
| 
      
 80 
     | 
    
         
            +
                  allow(entity).to receive_messages(:processes_by_name => {
         
     | 
| 
       81 
81 
     | 
    
         
             
                    :foof => bp = Bumbleworks::Process.new('1234')
         
     | 
| 
       82 
82 
     | 
    
         
             
                  })
         
     | 
| 
       83 
     | 
    
         
            -
                  bp. 
     | 
| 
       84 
     | 
    
         
            -
                  entity. 
     | 
| 
      
 83 
     | 
    
         
            +
                  expect(bp).to receive(:cancel!)
         
     | 
| 
      
 84 
     | 
    
         
            +
                  expect(entity).to receive(:update).never
         
     | 
| 
       85 
85 
     | 
    
         
             
                  entity.cancel_all_processes!(:clear_identifiers => false)
         
     | 
| 
       86 
86 
     | 
    
         
             
                end
         
     | 
| 
       87 
87 
     | 
    
         
             
              end
         
     | 
| 
         @@ -89,36 +89,34 @@ describe Bumbleworks::Entity do 
     | 
|
| 
       89 
89 
     | 
    
         
             
              describe '#process_fields' do
         
     | 
| 
       90 
90 
     | 
    
         
             
                it 'returns hash with entity' do
         
     | 
| 
       91 
91 
     | 
    
         
             
                  entity = entity_class.new
         
     | 
| 
       92 
     | 
    
         
            -
                  entity.process_fields. 
     | 
| 
      
 92 
     | 
    
         
            +
                  expect(entity.process_fields).to eq({ :entity => entity })
         
     | 
| 
       93 
93 
     | 
    
         
             
                end
         
     | 
| 
       94 
94 
     | 
    
         | 
| 
       95 
95 
     | 
    
         
             
                it 'accepts but ignores process name argument' do
         
     | 
| 
       96 
96 
     | 
    
         
             
                  entity = entity_class.new
         
     | 
| 
       97 
     | 
    
         
            -
                  entity.process_fields('ignore_me'). 
     | 
| 
      
 97 
     | 
    
         
            +
                  expect(entity.process_fields('ignore_me')).to eq({ :entity => entity })
         
     | 
| 
       98 
98 
     | 
    
         
             
                end
         
     | 
| 
       99 
99 
     | 
    
         
             
              end
         
     | 
| 
       100 
100 
     | 
    
         | 
| 
       101 
101 
     | 
    
         
             
              describe '#process_variables' do
         
     | 
| 
       102 
102 
     | 
    
         
             
                it 'returns empty hash' do
         
     | 
| 
       103 
     | 
    
         
            -
                  entity_class.new.process_variables. 
     | 
| 
      
 103 
     | 
    
         
            +
                  expect(entity_class.new.process_variables).to eq({})
         
     | 
| 
       104 
104 
     | 
    
         
             
                end
         
     | 
| 
       105 
105 
     | 
    
         | 
| 
       106 
106 
     | 
    
         
             
                it 'accepts but ignores process name argument' do
         
     | 
| 
       107 
     | 
    
         
            -
                  entity_class.new.process_variables('ignore me'). 
     | 
| 
      
 107 
     | 
    
         
            +
                  expect(entity_class.new.process_variables('ignore me')).to eq({})
         
     | 
| 
       108 
108 
     | 
    
         
             
                end
         
     | 
| 
       109 
109 
     | 
    
         
             
              end
         
     | 
| 
       110 
110 
     | 
    
         | 
| 
       111 
111 
     | 
    
         
             
              describe '#persist_process_identifier' do
         
     | 
| 
       112 
112 
     | 
    
         
             
                it 'calls #update if method exists' do
         
     | 
| 
       113 
113 
     | 
    
         
             
                  entity = entity_class.new
         
     | 
| 
       114 
     | 
    
         
            -
                  entity. 
     | 
| 
      
 114 
     | 
    
         
            +
                  expect(entity).to receive(:update).with(:a_attribute => :a_value)
         
     | 
| 
       115 
115 
     | 
    
         
             
                  entity.persist_process_identifier(:a_attribute, :a_value)
         
     | 
| 
       116 
116 
     | 
    
         
             
                end
         
     | 
| 
       117 
117 
     | 
    
         | 
| 
       118 
118 
     | 
    
         
             
                it 'raises exception if #update method does not exist' do
         
     | 
| 
       119 
119 
     | 
    
         
             
                  entity = entity_class.new
         
     | 
| 
       120 
     | 
    
         
            -
                  entity.stub(:respond_to?).with(:update).and_return(false)
         
     | 
| 
       121 
     | 
    
         
            -
                  entity.should_receive(:update).never
         
     | 
| 
       122 
120 
     | 
    
         
             
                  expect {
         
     | 
| 
       123 
121 
     | 
    
         
             
                    entity.persist_process_identifier(:a_attribute, :a_value)
         
     | 
| 
       124 
122 
     | 
    
         
             
                  }.to raise_error("Entity must define #persist_process_identifier method if missing #update method.")
         
     | 
| 
         @@ -130,39 +128,39 @@ describe Bumbleworks::Entity do 
     | 
|
| 
       130 
128 
     | 
    
         
             
                  bp = Bumbleworks::Process.new('12345')
         
     | 
| 
       131 
129 
     | 
    
         
             
                  entity_class.process :noodles, :attribute => :noodles_pid
         
     | 
| 
       132 
130 
     | 
    
         
             
                  entity = entity_class.new
         
     | 
| 
       133 
     | 
    
         
            -
                  entity. 
     | 
| 
       134 
     | 
    
         
            -
                  entity. 
     | 
| 
       135 
     | 
    
         
            -
                  entity. 
     | 
| 
       136 
     | 
    
         
            -
                  Bumbleworks. 
     | 
| 
       137 
     | 
    
         
            -
                  entity. 
     | 
| 
       138 
     | 
    
         
            -
                  entity.launch_process('noodles'). 
     | 
| 
      
 131 
     | 
    
         
            +
                  allow(entity).to receive(:noodles_pid)
         
     | 
| 
      
 132 
     | 
    
         
            +
                  allow(entity).to receive(:process_fields).with(:noodles).and_return({:f => 1})
         
     | 
| 
      
 133 
     | 
    
         
            +
                  allow(entity).to receive(:process_variables).with(:noodles).and_return({:v => 2})
         
     | 
| 
      
 134 
     | 
    
         
            +
                  allow(Bumbleworks).to receive(:launch!).with('noodles', {:f => 1}, {:v => 2}).and_return(bp)
         
     | 
| 
      
 135 
     | 
    
         
            +
                  expect(entity).to receive(:persist_process_identifier).with(:noodles_pid, '12345')
         
     | 
| 
      
 136 
     | 
    
         
            +
                  expect(entity.launch_process('noodles')).to eq(bp)
         
     | 
| 
       139 
137 
     | 
    
         
             
                end
         
     | 
| 
       140 
138 
     | 
    
         | 
| 
       141 
139 
     | 
    
         
             
                it 'does nothing but returns existing process if identifier attribute already set' do
         
     | 
| 
       142 
140 
     | 
    
         
             
                  bp = Bumbleworks::Process.new('already set')
         
     | 
| 
       143 
141 
     | 
    
         
             
                  entity_class.process :noodles, :attribute => :noodles_pid
         
     | 
| 
       144 
142 
     | 
    
         
             
                  entity = entity_class.new
         
     | 
| 
       145 
     | 
    
         
            -
                  entity. 
     | 
| 
       146 
     | 
    
         
            -
                  Bumbleworks. 
     | 
| 
       147 
     | 
    
         
            -
                  entity.launch_process('noodles'). 
     | 
| 
      
 143 
     | 
    
         
            +
                  allow(entity).to receive_messages(:noodles_pid => 'already set')
         
     | 
| 
      
 144 
     | 
    
         
            +
                  expect(Bumbleworks).to receive(:launch!).never
         
     | 
| 
      
 145 
     | 
    
         
            +
                  expect(entity.launch_process('noodles')).to eq(bp)
         
     | 
| 
       148 
146 
     | 
    
         
             
                end
         
     | 
| 
       149 
147 
     | 
    
         | 
| 
       150 
148 
     | 
    
         
             
                it 'launches new process anyway if identifier attribute already set but force is true' do
         
     | 
| 
       151 
149 
     | 
    
         
             
                  bp = Bumbleworks::Process.new('12345')
         
     | 
| 
       152 
150 
     | 
    
         
             
                  entity_class.process :noodles, :attribute => :noodles_pid
         
     | 
| 
       153 
151 
     | 
    
         
             
                  entity = entity_class.new
         
     | 
| 
       154 
     | 
    
         
            -
                  entity. 
     | 
| 
       155 
     | 
    
         
            -
                  Bumbleworks. 
     | 
| 
       156 
     | 
    
         
            -
                  entity. 
     | 
| 
       157 
     | 
    
         
            -
                  entity.launch_process('noodles', :force => true). 
     | 
| 
      
 152 
     | 
    
         
            +
                  allow(entity).to receive_messages(:noodles_pid => 'already set')
         
     | 
| 
      
 153 
     | 
    
         
            +
                  allow(Bumbleworks).to receive_messages(:launch! => bp)
         
     | 
| 
      
 154 
     | 
    
         
            +
                  expect(entity).to receive(:persist_process_identifier).with(:noodles_pid, '12345')
         
     | 
| 
      
 155 
     | 
    
         
            +
                  expect(entity.launch_process('noodles', :force => true)).to eq(bp)
         
     | 
| 
       158 
156 
     | 
    
         
             
                end
         
     | 
| 
       159 
157 
     | 
    
         | 
| 
       160 
158 
     | 
    
         
             
                it 'sends additional fields and variables to launch' do
         
     | 
| 
       161 
159 
     | 
    
         
             
                  entity_class.process :noodles, :attribute => :noodles_pid
         
     | 
| 
       162 
160 
     | 
    
         
             
                  entity = entity_class.new
         
     | 
| 
       163 
     | 
    
         
            -
                  entity. 
     | 
| 
       164 
     | 
    
         
            -
                  entity. 
     | 
| 
       165 
     | 
    
         
            -
                  Bumbleworks. 
     | 
| 
      
 161 
     | 
    
         
            +
                  allow(entity).to receive(:noodles_pid)
         
     | 
| 
      
 162 
     | 
    
         
            +
                  allow(entity).to receive(:persist_process_identifier)
         
     | 
| 
      
 163 
     | 
    
         
            +
                  expect(Bumbleworks).to receive(:launch!).with(
         
     | 
| 
       166 
164 
     | 
    
         
             
                    'noodles',
         
     | 
| 
       167 
165 
     | 
    
         
             
                    { :entity => entity, :drink => 'apathy smoothie', :berry => 'black' },
         
     | 
| 
       168 
166 
     | 
    
         
             
                    { :so_you_said => :well_so_did_i }
         
     | 
| 
         @@ -176,17 +174,17 @@ describe Bumbleworks::Entity do 
     | 
|
| 
       176 
174 
     | 
    
         | 
| 
       177 
175 
     | 
    
         
             
              describe '#attribute_for_process_name' do
         
     | 
| 
       178 
176 
     | 
    
         
             
                it 'returns attribute set for given process' do
         
     | 
| 
       179 
     | 
    
         
            -
                  entity_class. 
     | 
| 
      
 177 
     | 
    
         
            +
                  allow(entity_class).to receive(:processes).and_return({
         
     | 
| 
       180 
178 
     | 
    
         
             
                    :goose => { :attribute => :goose_pid },
         
     | 
| 
       181 
179 
     | 
    
         
             
                    :the_punisher => { :attribute => :your_skin }
         
     | 
| 
       182 
180 
     | 
    
         
             
                  })
         
     | 
| 
       183 
181 
     | 
    
         
             
                  entity = entity_class.new
         
     | 
| 
       184 
     | 
    
         
            -
                  entity.attribute_for_process_name(:goose). 
     | 
| 
       185 
     | 
    
         
            -
                  entity.attribute_for_process_name(:the_punisher). 
     | 
| 
      
 182 
     | 
    
         
            +
                  expect(entity.attribute_for_process_name(:goose)).to eq(:goose_pid)
         
     | 
| 
      
 183 
     | 
    
         
            +
                  expect(entity.attribute_for_process_name(:the_punisher)).to eq(:your_skin)
         
     | 
| 
       186 
184 
     | 
    
         
             
                end
         
     | 
| 
       187 
185 
     | 
    
         | 
| 
       188 
186 
     | 
    
         
             
                it 'raises exception if no process found for given name' do
         
     | 
| 
       189 
     | 
    
         
            -
                  entity_class. 
     | 
| 
      
 187 
     | 
    
         
            +
                  allow(entity_class).to receive(:processes).and_return({
         
     | 
| 
       190 
188 
     | 
    
         
             
                    :goose => { :attribute => :goose_pid },
         
     | 
| 
       191 
189 
     | 
    
         
             
                  })
         
     | 
| 
       192 
190 
     | 
    
         
             
                  entity = entity_class.new
         
     | 
| 
         @@ -201,11 +199,11 @@ describe Bumbleworks::Entity do 
     | 
|
| 
       201 
199 
     | 
    
         
             
                  bp1 = double('bp1', :subscribed_events => ['chewing', 'popping', 'yakking'])
         
     | 
| 
       202 
200 
     | 
    
         
             
                  bp2 = double('bp2', :subscribed_events => ['moon', 'yakking'])
         
     | 
| 
       203 
201 
     | 
    
         
             
                  entity = entity_class.new
         
     | 
| 
       204 
     | 
    
         
            -
                  entity. 
     | 
| 
      
 202 
     | 
    
         
            +
                  allow(entity).to receive(:processes).and_return({
         
     | 
| 
       205 
203 
     | 
    
         
             
                    :zip => bp1,
         
     | 
| 
       206 
204 
     | 
    
         
             
                    :yip => bp2
         
     | 
| 
       207 
205 
     | 
    
         
             
                  })
         
     | 
| 
       208 
     | 
    
         
            -
                  entity.subscribed_events. 
     | 
| 
      
 206 
     | 
    
         
            +
                  expect(entity.subscribed_events).to match_array(['chewing', 'moon', 'popping', 'yakking'])
         
     | 
| 
       209 
207 
     | 
    
         
             
                end
         
     | 
| 
       210 
208 
     | 
    
         
             
              end
         
     | 
| 
       211 
209 
     | 
    
         | 
| 
         @@ -214,42 +212,42 @@ describe Bumbleworks::Entity do 
     | 
|
| 
       214 
212 
     | 
    
         
             
                  bp1 = double('bp1', :subscribed_events => ['chewing', 'popping', 'yakking'])
         
     | 
| 
       215 
213 
     | 
    
         
             
                  bp2 = double('bp2', :subscribed_events => ['moon', 'yakking'])
         
     | 
| 
       216 
214 
     | 
    
         
             
                  entity = entity_class.new
         
     | 
| 
       217 
     | 
    
         
            -
                  entity. 
     | 
| 
      
 215 
     | 
    
         
            +
                  allow(entity).to receive(:processes).and_return({
         
     | 
| 
       218 
216 
     | 
    
         
             
                    :zip => bp1,
         
     | 
| 
       219 
217 
     | 
    
         
             
                    :yip => bp2
         
     | 
| 
       220 
218 
     | 
    
         
             
                  })
         
     | 
| 
       221 
     | 
    
         
            -
                  entity.is_waiting_for?('chewing'). 
     | 
| 
       222 
     | 
    
         
            -
                  entity.is_waiting_for?('yakking'). 
     | 
| 
       223 
     | 
    
         
            -
                  entity.is_waiting_for?(:moon). 
     | 
| 
       224 
     | 
    
         
            -
                  entity.is_waiting_for?('fruiting'). 
     | 
| 
      
 219 
     | 
    
         
            +
                  expect(entity.is_waiting_for?('chewing')).to be_truthy
         
     | 
| 
      
 220 
     | 
    
         
            +
                  expect(entity.is_waiting_for?('yakking')).to be_truthy
         
     | 
| 
      
 221 
     | 
    
         
            +
                  expect(entity.is_waiting_for?(:moon)).to be_truthy
         
     | 
| 
      
 222 
     | 
    
         
            +
                  expect(entity.is_waiting_for?('fruiting')).to be_falsy
         
     | 
| 
       225 
223 
     | 
    
         
             
                end
         
     | 
| 
       226 
224 
     | 
    
         
             
              end
         
     | 
| 
       227 
225 
     | 
    
         | 
| 
       228 
226 
     | 
    
         
             
              describe '#tasks' do
         
     | 
| 
       229 
227 
     | 
    
         
             
                it 'returns task query for all entity tasks by default' do
         
     | 
| 
       230 
228 
     | 
    
         
             
                  entity = entity_class.new
         
     | 
| 
       231 
     | 
    
         
            -
                  Bumbleworks::Task. 
     | 
| 
       232 
     | 
    
         
            -
                  entity.tasks. 
     | 
| 
      
 229 
     | 
    
         
            +
                  allow(Bumbleworks::Task).to receive(:for_entity).with(entity).and_return(:full_task_query)
         
     | 
| 
      
 230 
     | 
    
         
            +
                  expect(entity.tasks).to eq(:full_task_query)
         
     | 
| 
       233 
231 
     | 
    
         
             
                end
         
     | 
| 
       234 
232 
     | 
    
         | 
| 
       235 
233 
     | 
    
         
             
                it 'filters task query by nickname if provided' do
         
     | 
| 
       236 
234 
     | 
    
         
             
                  entity = entity_class.new
         
     | 
| 
       237 
235 
     | 
    
         
             
                  task_finder = double('task_finder')
         
     | 
| 
       238 
     | 
    
         
            -
                  task_finder. 
     | 
| 
       239 
     | 
    
         
            -
                  Bumbleworks::Task. 
     | 
| 
       240 
     | 
    
         
            -
                  entity.tasks(:smooface). 
     | 
| 
      
 236 
     | 
    
         
            +
                  allow(task_finder).to receive(:by_nickname).with(:smooface).and_return(:partial_task_query)
         
     | 
| 
      
 237 
     | 
    
         
            +
                  allow(Bumbleworks::Task).to receive(:for_entity).with(entity).and_return(task_finder)
         
     | 
| 
      
 238 
     | 
    
         
            +
                  expect(entity.tasks(:smooface)).to eq(:partial_task_query)
         
     | 
| 
       241 
239 
     | 
    
         
             
                end
         
     | 
| 
       242 
240 
     | 
    
         
             
              end
         
     | 
| 
       243 
241 
     | 
    
         | 
| 
       244 
242 
     | 
    
         
             
              describe '.process' do
         
     | 
| 
       245 
243 
     | 
    
         
             
                it 'registers a new process' do
         
     | 
| 
       246 
     | 
    
         
            -
                  entity_class. 
     | 
| 
      
 244 
     | 
    
         
            +
                  allow(entity_class).to receive(:default_process_identifier_attribute).with(:whatever).and_return('loob')
         
     | 
| 
       247 
245 
     | 
    
         
             
                  entity_class.process :whatever
         
     | 
| 
       248 
     | 
    
         
            -
                  entity_class.processes. 
     | 
| 
      
 246 
     | 
    
         
            +
                  expect(entity_class.processes).to eq({
         
     | 
| 
       249 
247 
     | 
    
         
             
                    :whatever => {
         
     | 
| 
       250 
248 
     | 
    
         
             
                      :attribute => 'loob'
         
     | 
| 
       251 
249 
     | 
    
         
             
                    }
         
     | 
| 
       252 
     | 
    
         
            -
                  }
         
     | 
| 
      
 250 
     | 
    
         
            +
                  })
         
     | 
| 
       253 
251 
     | 
    
         
             
                end
         
     | 
| 
       254 
252 
     | 
    
         
             
              end
         
     | 
| 
       255 
253 
     | 
    
         | 
| 
         @@ -261,23 +259,23 @@ describe Bumbleworks::Entity do 
     | 
|
| 
       261 
259 
     | 
    
         | 
| 
       262 
260 
     | 
    
         
             
              describe '.default_process_identifier_attribute' do
         
     | 
| 
       263 
261 
     | 
    
         
             
                it 'adds _process_identifier to end of given process name' do
         
     | 
| 
       264 
     | 
    
         
            -
                  entity_class.default_process_identifier_attribute('zoof'). 
     | 
| 
      
 262 
     | 
    
         
            +
                  expect(entity_class.default_process_identifier_attribute('zoof')).to eq(:zoof_process_identifier)
         
     | 
| 
       265 
263 
     | 
    
         
             
                end
         
     | 
| 
       266 
264 
     | 
    
         | 
| 
       267 
265 
     | 
    
         
             
                it 'ensures no duplication of _process' do
         
     | 
| 
       268 
     | 
    
         
            -
                  entity_class.default_process_identifier_attribute('zoof_process'). 
     | 
| 
      
 266 
     | 
    
         
            +
                  expect(entity_class.default_process_identifier_attribute('zoof_process')).to eq(:zoof_process_identifier)
         
     | 
| 
       269 
267 
     | 
    
         
             
                end
         
     | 
| 
       270 
268 
     | 
    
         | 
| 
       271 
269 
     | 
    
         
             
                it 'removes entity_type from beginning of identifier' do
         
     | 
| 
       272 
     | 
    
         
            -
                  entity_class. 
     | 
| 
       273 
     | 
    
         
            -
                  entity_class.default_process_identifier_attribute('zoof_process'). 
     | 
| 
      
 270 
     | 
    
         
            +
                  allow(entity_class).to receive(:entity_type).and_return('zoof')
         
     | 
| 
      
 271 
     | 
    
         
            +
                  expect(entity_class.default_process_identifier_attribute('zoof_process')).to eq(:process_identifier)
         
     | 
| 
       274 
272 
     | 
    
         
             
                end
         
     | 
| 
       275 
273 
     | 
    
         
             
              end
         
     | 
| 
       276 
274 
     | 
    
         | 
| 
       277 
275 
     | 
    
         
             
              describe '.entity_type' do
         
     | 
| 
       278 
276 
     | 
    
         
             
                it 'returns underscored version of class name' do
         
     | 
| 
       279 
     | 
    
         
            -
                  entity_class. 
     | 
| 
       280 
     | 
    
         
            -
                  entity_class.entity_type. 
     | 
| 
      
 277 
     | 
    
         
            +
                  allow(entity_class).to receive(:name).and_return('MyClass')
         
     | 
| 
      
 278 
     | 
    
         
            +
                  expect(entity_class.entity_type).to eq('my_class')
         
     | 
| 
       281 
279 
     | 
    
         
             
                end
         
     | 
| 
       282 
280 
     | 
    
         
             
              end
         
     | 
| 
       283 
281 
     | 
    
         
             
            end
         
     |