batsir 0.3.7.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGES.md +9 -0
  3. data/README.md +1 -1
  4. data/lib/batsir/compiler/stage_worker_compiler.rb +42 -27
  5. data/lib/batsir/dsl/conditional_notifier_declaration.rb +7 -7
  6. data/lib/batsir/version.rb +3 -3
  7. metadata +81 -151
  8. data/.document +0 -5
  9. data/.rspec +0 -3
  10. data/.travis.yml +0 -18
  11. data/Gemfile +0 -19
  12. data/Rakefile +0 -62
  13. data/batsir.gemspec +0 -132
  14. data/batsir.png +0 -0
  15. data/spec/batsir/acceptors/acceptor_spec.rb +0 -65
  16. data/spec/batsir/acceptors/amqp_acceptor_spec.rb +0 -158
  17. data/spec/batsir/acceptors/shared_examples.rb +0 -102
  18. data/spec/batsir/amqp_spec.rb +0 -58
  19. data/spec/batsir/chain_spec.rb +0 -31
  20. data/spec/batsir/config_spec.rb +0 -97
  21. data/spec/batsir/dsl/chain_mapping_spec.rb +0 -116
  22. data/spec/batsir/dsl/conditional_notifier_mapping_spec.rb +0 -80
  23. data/spec/batsir/dsl/stage_mapping_spec.rb +0 -453
  24. data/spec/batsir/filter_queue_spec.rb +0 -68
  25. data/spec/batsir/filter_spec.rb +0 -11
  26. data/spec/batsir/log_spec.rb +0 -10
  27. data/spec/batsir/logger_spec.rb +0 -46
  28. data/spec/batsir/notifiers/amqp_notifier_spec.rb +0 -138
  29. data/spec/batsir/notifiers/conditional_notifier_spec.rb +0 -62
  30. data/spec/batsir/notifiers/notifier_spec.rb +0 -11
  31. data/spec/batsir/notifiers/shared_examples.rb +0 -100
  32. data/spec/batsir/registry_spec.rb +0 -48
  33. data/spec/batsir/stage_spec.rb +0 -684
  34. data/spec/batsir/stage_worker_spec.rb +0 -128
  35. data/spec/batsir/strategies/retry_strategy_spec.rb +0 -58
  36. data/spec/batsir/strategies/strategy_spec.rb +0 -28
  37. data/spec/batsir/support/bunny_mocks.rb +0 -135
  38. data/spec/batsir/support/mock_filters.rb +0 -43
  39. data/spec/batsir/transformers/field_transformer_spec.rb +0 -73
  40. data/spec/batsir/transformers/json_input_transformer_spec.rb +0 -27
  41. data/spec/batsir/transformers/json_output_transformer_spec.rb +0 -18
  42. data/spec/batsir/transformers/transformer_spec.rb +0 -36
  43. data/spec/spec_helper.rb +0 -26
@@ -1,116 +0,0 @@
1
- require File.join( File.dirname(__FILE__), "..", "..", "spec_helper")
2
-
3
- describe Batsir::DSL::ChainMapping do
4
- it "creates a chain" do
5
- block = ::Proc.new do
6
- aggregator_chain do
7
- end
8
- end
9
-
10
- chain = ::Blockenspiel.invoke(block, Batsir::DSL::ChainMapping.new)
11
- chain.should_not be_nil
12
- end
13
-
14
- it "can add a stage" do
15
- block = ::Proc.new do
16
- aggregator_chain do
17
- stage "simple_stage" do
18
-
19
- end
20
- end
21
- end
22
-
23
- chain = ::Blockenspiel.invoke(block, Batsir::DSL::ChainMapping.new)
24
- chain.stages.should_not be_empty
25
- chain.stages.size.should == 1
26
- chain.stages.first.name.should == "simple_stage"
27
- end
28
-
29
- it "sets the chain of the stage to the current chain" do
30
- block = ::Proc.new do
31
- aggregator_chain do
32
- stage "simple_stage" do
33
-
34
- end
35
- end
36
- end
37
-
38
- chain = ::Blockenspiel.invoke(block, Batsir::DSL::ChainMapping.new)
39
- chain.stages.size.should == 1
40
- chain.stages.first.chain.should == chain
41
- end
42
-
43
- it "can add multiple stages" do
44
- block = ::Proc.new do
45
- aggregator_chain do
46
- stage "first_stage" do
47
-
48
- end
49
- stage "second_stage" do
50
-
51
- end
52
- end
53
- end
54
-
55
- chain = ::Blockenspiel.invoke(block, Batsir::DSL::ChainMapping.new)
56
- chain.stages.should_not be_empty
57
- chain.stages.size.should == 2
58
- chain.stages.first.name.should == "first_stage"
59
- chain.stages.last.name.should == "second_stage"
60
- end
61
-
62
- it "can create a complete aggregator chain" do
63
- stage_name = "Complete Stage"
64
- operation1 = "Some Operation"
65
- operation2 = "Another Operation"
66
- notification_class1 = :notification_class1
67
- options = {:queue => :somequeue}
68
- notification_class2 = :notification_class2
69
-
70
- block = ::Proc.new do
71
- aggregator_chain do
72
- stage stage_name do
73
- filter operation1
74
- filter operation2
75
- outbound do
76
- notifier notification_class1, options
77
- notifier notification_class2
78
- end
79
- end
80
-
81
- stage "#{stage_name}2" do
82
- filter operation1
83
- filter operation2
84
- outbound do
85
- notifier notification_class1, options
86
- notifier notification_class2
87
- end
88
- end
89
- end
90
- end
91
-
92
- chain = ::Blockenspiel.invoke(block, Batsir::DSL::ChainMapping.new)
93
- chain.should_not be_nil
94
- chain.stages.size.should == 2
95
- stage1 = chain.stages.first
96
- stage1.should_not be_nil
97
- stage1.name.should == stage_name
98
-
99
- stage2 = chain.stages.last
100
- stage2.should_not be_nil
101
- stage2.name.should == "#{stage_name}2"
102
-
103
- chain.stages.each do |stage|
104
- stage.filters.should_not be_nil
105
- stage.filters.should_not be_empty
106
- stage.filters.should include operation1
107
- stage.filters.should include operation2
108
- stage.notifiers.should_not be_nil
109
- stage.notifiers.should_not be_empty
110
- stage.notifiers.should have_key notification_class1
111
- stage.notifiers[notification_class1].first.should == options
112
- stage.notifiers.should have_key notification_class2
113
- stage.notifiers[notification_class2].first.should == {}
114
- end
115
- end
116
- end
@@ -1,80 +0,0 @@
1
- require File.join( File.dirname(__FILE__), "..", "..", "spec_helper")
2
-
3
- describe Batsir::DSL::ConditionalNotifierMapping do
4
- it "creates conditional notifier declarations" do
5
- block = lambda do
6
- conditional do
7
- notify_if "message == 'sometext'", Batsir::Notifiers::Notifier
8
- end
9
- end
10
-
11
- conditional = ::Blockenspiel.invoke(block, Batsir::DSL::ConditionalNotifierMapping.new)
12
- conditional.notifier_declarations.should_not be_empty
13
- conditional_notifier = conditional.notifier_declarations.first
14
- conditional_notifier.notifier.should == Batsir::Notifiers::Notifier
15
- end
16
-
17
- it "passes options to notifiers" do
18
- block = lambda do
19
- conditional do
20
- notify_if "true", Batsir::Notifiers::Notifier, :some => :options
21
- end
22
- end
23
-
24
- conditional = ::Blockenspiel.invoke(block, Batsir::DSL::ConditionalNotifierMapping.new)
25
- conditional.notifier_declarations.should_not be_empty
26
- conditional_notifier = conditional.notifier_declarations.first
27
- conditional_notifier.options.should have_key :some
28
- end
29
-
30
- it "can be used inside a stage" do
31
- block = lambda do
32
- stage "stage name" do
33
- outbound do
34
- conditional do
35
- notify_if "true", Batsir::Notifiers::Notifier, :some => :options
36
- end
37
- end
38
- end
39
- end
40
-
41
- stage = ::Blockenspiel.invoke(block, Batsir::DSL::StageMapping.new)
42
- notifier = stage.conditional_notifiers.should_not be_empty
43
- end
44
-
45
- context "compiling" do
46
- before :all do
47
- Celluloid.boot
48
-
49
- block = lambda do
50
- stage "stage name" do
51
- outbound do
52
- conditional do
53
- notify_if "true", Batsir::Notifiers::Notifier
54
- notify_if "false", Batsir::Notifiers::Notifier
55
- end
56
- end
57
- end
58
- end
59
-
60
- stage = ::Blockenspiel.invoke(block, Batsir::DSL::StageMapping.new)
61
- created_class = eval( stage.compile )
62
- @instance = created_class.new
63
- end
64
-
65
- it "stores the conditional notifier" do
66
- @instance.filter_queue.notifiers.size == 1
67
- conditional = @instance.filter_queue.notifiers.first
68
- conditional.should be_kind_of Batsir::Notifiers::ConditionalNotifier
69
- conditional.notifiers.size.should == 2
70
- conditional.notifiers.first.condition.should be_a Proc
71
- end
72
-
73
- it "adds the default transformer" do
74
- notifier = @instance.filter_queue.notifiers.first
75
- notifier.transformer_queue.size.should == 1
76
- notifier.transformer_queue.first.should be_kind_of Batsir::Transformers::Transformer
77
- end
78
- end
79
- end
80
-
@@ -1,453 +0,0 @@
1
- require File.join( File.dirname(__FILE__), "..", "..", "spec_helper")
2
-
3
- describe Batsir::DSL::StageMapping do
4
- it "creates a simple stage with a name" do
5
- block = ::Proc.new do
6
- stage "simple_stage" do
7
- end
8
- end
9
-
10
- stage = ::Blockenspiel.invoke(block, Batsir::DSL::StageMapping.new)
11
- stage.should_not be_nil
12
- stage.name.should == "simple_stage"
13
- end
14
-
15
- it "can add a filter to the stage" do
16
- filter = "Operation"
17
-
18
- block = ::Proc.new do
19
- stage "simple_stage" do
20
- filter filter
21
- end
22
- end
23
-
24
- stage = ::Blockenspiel.invoke(block, Batsir::DSL::StageMapping.new)
25
- stage.should_not be_nil
26
- stage.filters.should_not be_nil
27
- stage.filters.should_not be_empty
28
- stage.filters.should include filter
29
- end
30
-
31
- it "can add a filter with options to the stage" do
32
- filter = "Operation"
33
- options = { :option => "options" }
34
-
35
- block = ::Proc.new do
36
- stage "simple_stage" do
37
- filter filter, options
38
- end
39
- end
40
-
41
- stage = ::Blockenspiel.invoke(block, Batsir::DSL::StageMapping.new)
42
- stage.should_not be_nil
43
- stage.filters.should_not be_nil
44
- stage.filters.should_not be_empty
45
- declaration = stage.filter_declarations.find{|decl| decl.filter == filter }
46
- declaration.options.should == options
47
- end
48
-
49
- it "can add multiple filters to the stage" do
50
- filter1 = "Operation 1"
51
- filter2 = "Operation 2"
52
-
53
- block = ::Proc.new do
54
- stage "simple_stage" do
55
- filter filter1
56
- filter filter2
57
- end
58
- end
59
-
60
- stage = ::Blockenspiel.invoke(block, Batsir::DSL::StageMapping.new)
61
- stage.should_not be_nil
62
- stage.filters.should_not be_nil
63
- stage.filters.should_not be_empty
64
- stage.filters.should include filter1
65
- stage.filters.should include filter2
66
- end
67
-
68
- it "can add an inbound section to a stage" do
69
- block = ::Proc.new do
70
- stage "simple_stage" do
71
- inbound do
72
-
73
- end
74
- end
75
- end
76
-
77
- stage = ::Blockenspiel.invoke(block, Batsir::DSL::StageMapping.new)
78
- stage.should_not be_nil
79
- stage.acceptors.should_not be_nil
80
- stage.acceptors.should be_empty
81
- end
82
-
83
- it "can add a transformers section to the inbound section of a stage" do
84
- block = ::Proc.new do
85
- stage "simple_stage" do
86
- inbound do
87
- transformers do
88
-
89
- end
90
- end
91
- end
92
- end
93
-
94
- stage = ::Blockenspiel.invoke(block, Batsir::DSL::StageMapping.new)
95
- stage.should_not be_nil
96
- stage.acceptors.should_not be_nil
97
- stage.acceptors.should be_empty
98
- stage.acceptor_transformers.should be_empty
99
- end
100
-
101
- it "can add a transformer to the transformers section of the inbound section of a stage" do
102
- transformer = :transformer
103
-
104
- block = ::Proc.new do
105
- stage "simple_stage" do
106
- inbound do
107
- transformers do
108
- transformer transformer
109
- end
110
- end
111
- end
112
- end
113
-
114
- stage = ::Blockenspiel.invoke(block, Batsir::DSL::StageMapping.new)
115
- stage.should_not be_nil
116
- stage.acceptors.should_not be_nil
117
- stage.acceptors.should be_empty
118
- stage.acceptor_transformers.should_not be_empty
119
- stage.acceptor_transformers.size.should == 1
120
- stage.acceptor_transformers.first.transformer.should == transformer
121
- end
122
-
123
- it "can add a transformer with options to the transformers section of the inbound section of a stage" do
124
- transformer = :transformer
125
- options = {:foo => :bar}
126
-
127
- block = ::Proc.new do
128
- stage "simple_stage" do
129
- inbound do
130
- transformers do
131
- transformer transformer, options
132
- end
133
- end
134
- end
135
- end
136
-
137
- stage = ::Blockenspiel.invoke(block, Batsir::DSL::StageMapping.new)
138
- stage.should_not be_nil
139
- stage.acceptors.should_not be_nil
140
- stage.acceptors.should be_empty
141
- stage.acceptor_transformers.should_not be_empty
142
- stage.acceptor_transformers.size.should == 1
143
- stage.acceptor_transformers.first.transformer.should == transformer
144
- stage.acceptor_transformers.first.options.should == options
145
- end
146
-
147
- it "can add multiple transformers to the transformers section of the inbound section of a stage" do
148
- transformer1 = :transformer1
149
- options = {:foo => :bar}
150
- transformer2 = :transformer2
151
-
152
- block = ::Proc.new do
153
- stage "simple_stage" do
154
- inbound do
155
- transformers do
156
- transformer transformer1, options
157
- transformer transformer2
158
- end
159
- end
160
- end
161
- end
162
-
163
- stage = ::Blockenspiel.invoke(block, Batsir::DSL::StageMapping.new)
164
- stage.should_not be_nil
165
- stage.acceptors.should_not be_nil
166
- stage.acceptors.should be_empty
167
- stage.acceptor_transformers.should_not be_empty
168
- stage.acceptor_transformers.size.should == 2
169
- stage.acceptor_transformers.first.transformer.should == transformer1
170
- stage.acceptor_transformers.first.options.should == options
171
- stage.acceptor_transformers.last.transformer.should == transformer2
172
- stage.acceptor_transformers.last.options.should == {}
173
- end
174
-
175
- it "can add an acceptor to a stage" do
176
- acceptor_class = :acceptor_class
177
-
178
- block = ::Proc.new do
179
- stage "simple_stage" do
180
- inbound do
181
- acceptor acceptor_class
182
- end
183
- end
184
- end
185
-
186
- stage = ::Blockenspiel.invoke(block, Batsir::DSL::StageMapping.new)
187
- stage.should_not be_nil
188
- stage.acceptors.should_not be_nil
189
- stage.acceptors.should_not be_empty
190
- stage.acceptors.keys.should include acceptor_class
191
- stage.acceptors[acceptor_class].first.should == {}
192
- end
193
-
194
- it "can add an inbound section with an acceptor with options to the stage" do
195
- acceptor_class = :acceptor_class
196
- options = {:foo => :bar}
197
-
198
- block = ::Proc.new do
199
- stage "simple_stage" do
200
- inbound do
201
- acceptor acceptor_class, options
202
- end
203
- end
204
- end
205
-
206
- stage = ::Blockenspiel.invoke(block, Batsir::DSL::StageMapping.new)
207
- stage.should_not be_nil
208
- stage.acceptors.should_not be_nil
209
- stage.acceptors.should_not be_empty
210
- stage.acceptors.keys.should include acceptor_class
211
- stage.acceptors[acceptor_class].first.should == options
212
- end
213
-
214
- it "can add multiple acceptors to a stage" do
215
- acceptor_class1 = :acceptor_class1
216
- options = {:foo => :bar}
217
- acceptor_class2 = :acceptor_class2
218
-
219
- block = ::Proc.new do
220
- stage "simple_stage" do
221
- inbound do
222
- acceptor acceptor_class1, options
223
- acceptor acceptor_class2
224
- end
225
- end
226
- end
227
-
228
- stage = ::Blockenspiel.invoke(block, Batsir::DSL::StageMapping.new)
229
- stage.should_not be_nil
230
- stage.acceptors.should_not be_nil
231
- stage.acceptors.should_not be_empty
232
- stage.acceptors.keys.should include acceptor_class1
233
- stage.acceptors[acceptor_class1].first.should == options
234
- stage.acceptors.keys.should include acceptor_class2
235
- stage.acceptors[acceptor_class2].first.should == {}
236
- end
237
-
238
- it "can add an outbound section without any notifiers" do
239
- block = ::Proc.new do
240
- stage "simple_stage" do
241
- outbound do
242
-
243
- end
244
- end
245
- end
246
-
247
- stage = ::Blockenspiel.invoke(block, Batsir::DSL::StageMapping.new)
248
- stage.should_not be_nil
249
- stage.notifiers.should_not be_nil
250
- stage.notifiers.should be_empty
251
- end
252
-
253
- it "can add a transformers section to the outbound section of a stage" do
254
- block = ::Proc.new do
255
- stage "simple_stage" do
256
- outbound do
257
- transformers do
258
-
259
- end
260
- end
261
- end
262
- end
263
-
264
- stage = ::Blockenspiel.invoke(block, Batsir::DSL::StageMapping.new)
265
- stage.should_not be_nil
266
- stage.notifiers.should_not be_nil
267
- stage.notifiers.should be_empty
268
- stage.notifier_transformers.should be_empty
269
- end
270
-
271
- it "can add a transformer to the transformers section of the outbound section of a stage" do
272
- transformer = :transformer
273
-
274
- block = ::Proc.new do
275
- stage "simple_stage" do
276
- outbound do
277
- transformers do
278
- transformer transformer
279
- end
280
- end
281
- end
282
- end
283
-
284
- stage = ::Blockenspiel.invoke(block, Batsir::DSL::StageMapping.new)
285
- stage.should_not be_nil
286
- stage.notifiers.should_not be_nil
287
- stage.notifiers.should be_empty
288
- stage.notifier_transformers.should_not be_empty
289
- stage.notifier_transformers.size.should == 1
290
- stage.notifier_transformers.first.transformer.should == transformer
291
- end
292
-
293
- it "can add a transformer with options to the transformers section of the outbound section of a stage" do
294
- transformer = :transformer
295
- options = {:foo => :bar}
296
-
297
- block = ::Proc.new do
298
- stage "simple_stage" do
299
- outbound do
300
- transformers do
301
- transformer transformer, options
302
- end
303
- end
304
- end
305
- end
306
-
307
- stage = ::Blockenspiel.invoke(block, Batsir::DSL::StageMapping.new)
308
- stage.should_not be_nil
309
- stage.notifiers.should_not be_nil
310
- stage.notifiers.should be_empty
311
- stage.notifier_transformers.should_not be_empty
312
- stage.notifier_transformers.size.should == 1
313
- stage.notifier_transformers.first.transformer.should == transformer
314
- stage.notifier_transformers.first.options.should == options
315
- end
316
-
317
- it "can add multiple transformers to the transformers section of the outbound section of a stage" do
318
- transformer1 = :transformer1
319
- options = {:foo => :bar}
320
- transformer2 = :transformer2
321
-
322
- block = ::Proc.new do
323
- stage "simple_stage" do
324
- outbound do
325
- transformers do
326
- transformer transformer1, options
327
- transformer transformer2
328
- end
329
- end
330
- end
331
- end
332
-
333
- stage = ::Blockenspiel.invoke(block, Batsir::DSL::StageMapping.new)
334
- stage.should_not be_nil
335
- stage.notifiers.should_not be_nil
336
- stage.notifiers.should be_empty
337
- stage.notifier_transformers.should_not be_empty
338
- stage.notifier_transformers.size.should == 2
339
- stage.notifier_transformers.first.transformer.should == transformer1
340
- stage.notifier_transformers.first.options.should == options
341
- stage.notifier_transformers.last.transformer.should == transformer2
342
- stage.notifier_transformers.last.options.should == {}
343
- end
344
-
345
- it "can add an outbound section to the stage" do
346
- notification_class = :notification_class
347
-
348
- block = ::Proc.new do
349
- stage "simple_stage" do
350
- outbound do
351
- notifier notification_class
352
- end
353
- end
354
- end
355
-
356
- stage = ::Blockenspiel.invoke(block, Batsir::DSL::StageMapping.new)
357
- stage.should_not be_nil
358
- stage.notifiers.should_not be_empty
359
- stage.notifiers.should have_key notification_class
360
- stage.notifiers[notification_class].first.should == {}
361
- end
362
-
363
- it "can add an outbound section with a notifier with options to the stage" do
364
- notification_class = :notification_class
365
- options = {:queue => :somequeue}
366
-
367
- block = ::Proc.new do
368
- stage "simple_stage" do
369
- outbound do
370
- notifier notification_class, options
371
- end
372
- end
373
- end
374
-
375
- stage = ::Blockenspiel.invoke(block, Batsir::DSL::StageMapping.new)
376
- stage.should_not be_nil
377
- stage.notifiers.should_not be_empty
378
- stage.notifiers.should have_key notification_class
379
- stage.notifiers[notification_class].first.should == options
380
- end
381
-
382
- it "can add multiple notifiers to the stage" do
383
- notification_class1 = :notification_class1
384
- options = {:queue => :somequeue}
385
- notification_class2 = :notification_class2
386
-
387
- block = ::Proc.new do
388
- stage "simple_stage" do
389
- outbound do
390
- notifier notification_class1, options
391
- notifier notification_class2
392
- end
393
- end
394
- end
395
-
396
- stage = ::Blockenspiel.invoke(block, Batsir::DSL::StageMapping.new)
397
- stage.should_not be_nil
398
- stage.notifiers.should_not be_empty
399
- stage.notifiers.should have_key notification_class1
400
- stage.notifiers[notification_class1].first.should == options
401
-
402
- stage.notifiers.should have_key notification_class2
403
- stage.notifiers[notification_class2].first.should == {}
404
- end
405
-
406
- it "can create a complete stage" do
407
- acceptor_class1 = :acceptor_class1
408
- options = {:foo => :bar}
409
- acceptor_class2 = :acceptor_class2
410
- stage_name = "Complete Stage"
411
- filter1 = "Some Filter"
412
- filter2 = "Another Filter"
413
- notification_class1 = :notification_class1
414
- options = {:queue => :somequeue}
415
- notification_class2 = :notification_class2
416
-
417
- block = ::Proc.new do
418
- stage stage_name do
419
- inbound do
420
- acceptor acceptor_class1, options
421
- acceptor acceptor_class2
422
- end
423
- filter filter1
424
- filter filter2
425
- outbound do
426
- notifier notification_class1, options
427
- notifier notification_class2
428
- end
429
- end
430
- end
431
-
432
- stage = ::Blockenspiel.invoke(block, Batsir::DSL::StageMapping.new)
433
- stage.should_not be_nil
434
- stage.name.should == stage_name
435
- stage.acceptors.should_not be_nil
436
- stage.acceptors.should_not be_empty
437
- stage.acceptors.keys.should include acceptor_class1
438
- stage.acceptors[acceptor_class1].first.should == options
439
- stage.acceptors.keys.should include acceptor_class2
440
- stage.acceptors[acceptor_class2].first.should == {}
441
- stage.filters.should_not be_nil
442
- stage.filters.should_not be_empty
443
- stage.filters.should include filter1
444
- stage.filters.should include filter2
445
- stage.notifiers.should_not be_nil
446
- stage.notifiers.should_not be_empty
447
- stage.notifiers.should have_key notification_class1
448
- stage.notifiers[notification_class1].first.should == options
449
-
450
- stage.notifiers.should have_key notification_class2
451
- stage.notifiers[notification_class2].first.should == {}
452
- end
453
- end
@@ -1,68 +0,0 @@
1
- require File.join( File.dirname(__FILE__), "..", "spec_helper" )
2
-
3
- describe Batsir::FilterQueue do
4
- it "can add a filter to a queue" do
5
- queue = Batsir::FilterQueue.new
6
- queue.add("Filter")
7
- queue.should include "Filter"
8
- end
9
-
10
- it "does not return nil as last operation when no acceptors or notifiers are added" do
11
- queue = Batsir::FilterQueue.new
12
- queue.add("AnotherFilter")
13
- ops = []
14
- queue.each do |op|
15
- ops << op
16
- end
17
- ops.last.should_not be_nil
18
- end
19
-
20
- it "can add a notifier" do
21
- queue = Batsir::FilterQueue.new
22
- notifier = "Notifier"
23
- queue.add_notifier(notifier)
24
- queue.should include notifier
25
- end
26
-
27
- it "can add multiple notifiers" do
28
- queue = Batsir::FilterQueue.new
29
- ops = []
30
- 3.times do |index|
31
- ops << "Notifier #{index}"
32
- queue.add_notifier("Notifier #{index}")
33
- end
34
- ops.each {|op| queue.should include op}
35
- end
36
-
37
- it "returns notifiers as the last operations" do
38
- notifier = "Notifier"
39
- queue = Batsir::FilterQueue.new
40
- queue.add("SomeFilter")
41
- queue.add_notifier(notifier)
42
- queue.add("AnotherFilter")
43
-
44
- ops = []
45
- queue.each do |op|
46
- ops << op
47
- end
48
- ops.last.should == notifier
49
- end
50
-
51
- it "responds true to #empty? when no operations are added" do
52
- queue = Batsir::FilterQueue.new
53
- queue.should be_empty
54
- end
55
-
56
- it "is not empty when a notification operation is added" do
57
- queue = Batsir::FilterQueue.new
58
- operation = "Notifier"
59
- queue.add_notifier(operation)
60
- queue.should_not be_empty
61
- end
62
-
63
- it "is not empty when a regular operation is added" do
64
- queue = Batsir::FilterQueue.new
65
- queue.add("SomeFilter")
66
- queue.should_not be_empty
67
- end
68
- end