ruote-kit 2.1.11 → 2.2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. data/CHANGELOG.txt +6 -1
  2. data/CREDITS.txt +23 -0
  3. data/LICENSE.txt +1 -1
  4. data/README.rdoc +44 -7
  5. data/Rakefile +78 -45
  6. data/TODO.txt +8 -0
  7. data/lib/ruote-kit/helpers/json_helpers.rb +1 -1
  8. data/lib/ruote-kit/helpers/misc_helpers.rb +1 -1
  9. data/lib/ruote-kit/helpers/render_helpers.rb +18 -1
  10. data/lib/ruote-kit/public/_ruote/stylesheets/ruote-fluo-editor.css +1 -1
  11. data/lib/ruote-kit/resources/expressions.rb +6 -0
  12. data/lib/ruote-kit/resources/participants.rb +3 -1
  13. data/lib/ruote-kit/resources/schedules.rb +1 -1
  14. data/lib/ruote-kit/resources/workitems.rb +4 -0
  15. data/lib/ruote-kit/version.rb +1 -1
  16. data/lib/ruote-kit/views/expression.html.haml +2 -2
  17. data/lib/ruote-kit/views/layout.html.haml +1 -1
  18. data/lib/ruote-kit/views/participants.html.haml +19 -18
  19. data/lib/ruote-kit.rb +13 -3
  20. data/ruote-kit.gemspec +34 -133
  21. data/spec/resources/errors_spec.rb +20 -8
  22. data/spec/resources/expressions_spec.rb +211 -45
  23. data/spec/resources/index_spec.rb +1 -5
  24. data/spec/resources/participants_spec.rb +26 -9
  25. data/spec/resources/processes_spec.rb +77 -41
  26. data/spec/resources/schedules_spec.rb +33 -9
  27. data/spec/resources/workitems_spec.rb +174 -83
  28. data/spec/spec_helper.rb +11 -56
  29. data/spec/support/engine_helper.rb +97 -0
  30. data/spec/support/rack_helper.rb +21 -0
  31. data/spec/support/render_helper.rb +16 -0
  32. data/spec/webapp_helpers_spec.rb +1 -0
  33. metadata +121 -121
  34. data/.document +0 -0
  35. data/.gitignore +0 -10
  36. data/Gemfile +0 -51
  37. data/config.ru +0 -60
  38. data/lib/ruote-kit/spec/ruote_helpers.rb +0 -56
  39. data/spec/it_has_an_engine.rb +0 -69
  40. data/spec/spec.opts +0 -1
@@ -1,14 +1,23 @@
1
1
 
2
- require 'spec_helper'
2
+ require File.join(File.dirname(__FILE__), '..', 'spec_helper.rb')
3
3
 
4
4
 
5
5
  describe 'GET /_ruote/participants' do
6
6
 
7
- describe 'without any participant' do
7
+ before(:each) do
8
+
9
+ prepare_engine
10
+ end
8
11
 
9
- it_has_an_engine_with_no_participants
12
+ after(:each) do
13
+
14
+ shutdown_and_purge_engine
15
+ end
16
+
17
+ describe 'without any participant' do
10
18
 
11
19
  it 'should give an empty list (HTML)' do
20
+
12
21
  get '/_ruote/participants'
13
22
 
14
23
  last_response.status.should be(200)
@@ -29,7 +38,10 @@ describe 'GET /_ruote/participants' do
29
38
 
30
39
  describe 'with participant' do
31
40
 
32
- it_has_an_engine
41
+ before(:each) do
42
+
43
+ register_participants
44
+ end
33
45
 
34
46
  it 'should give participant information back (HTML)' do
35
47
 
@@ -43,17 +55,22 @@ describe 'GET /_ruote/participants' do
43
55
  get '/_ruote/participants.json'
44
56
 
45
57
  last_response.status.should be(200)
46
-
47
- body = last_response.json_body
48
-
49
- body['participants'].should_not be_empty
58
+ last_response.json_body['participants'].should_not be_empty
50
59
  end
51
60
  end
52
61
  end
53
62
 
54
63
  describe 'PUT /_ruote/participants' do
55
64
 
56
- it_has_an_engine
65
+ before(:each) do
66
+
67
+ prepare_engine
68
+ end
69
+
70
+ after(:each) do
71
+
72
+ shutdown_and_purge_engine
73
+ end
57
74
 
58
75
  it 'should update the list (HTML)' do
59
76
 
@@ -1,7 +1,5 @@
1
1
 
2
- require 'spec_helper'
3
-
4
- undef :context if defined?(context)
2
+ require File.join(File.dirname(__FILE__), '..', 'spec_helper.rb')
5
3
 
6
4
 
7
5
  def process_links(wfid)
@@ -24,7 +22,15 @@ end
24
22
 
25
23
  describe 'GET /_ruote/processes' do
26
24
 
27
- it_has_an_engine
25
+ before(:each) do
26
+
27
+ prepare_engine_with_participants
28
+ end
29
+
30
+ after(:each) do
31
+
32
+ shutdown_and_purge_engine
33
+ end
28
34
 
29
35
  describe 'without any running processes' do
30
36
 
@@ -32,7 +38,7 @@ describe 'GET /_ruote/processes' do
32
38
 
33
39
  get '/_ruote/processes?limit=100&skip=0'
34
40
 
35
- last_response.status.should be(200)
41
+ last_response.status.should == 200
36
42
 
37
43
  last_response.should have_selector(
38
44
  'a', :content => 'as JSON')
@@ -44,7 +50,7 @@ describe 'GET /_ruote/processes' do
44
50
 
45
51
  get '/_ruote/processes.json'
46
52
 
47
- last_response.status.should be(200)
53
+ last_response.status.should == 200
48
54
 
49
55
  body = last_response.json_body
50
56
  body.should have_key('processes')
@@ -56,21 +62,21 @@ describe 'GET /_ruote/processes' do
56
62
  describe 'with running processes' do
57
63
 
58
64
  before(:each) do
59
- @wfid = launch_test_process
65
+ @wfid = launch_nada_process
60
66
  end
61
67
 
62
68
  it 'should give process information back (HTML)' do
63
69
 
64
70
  get '/_ruote/processes'
65
71
 
66
- last_response.status.should be(200)
72
+ last_response.status.should == 200
67
73
  end
68
74
 
69
75
  it 'should give process information back (JSON)' do
70
76
 
71
77
  get '/_ruote/processes.json'
72
78
 
73
- last_response.status.should be(200)
79
+ last_response.status.should == 200
74
80
 
75
81
  body = last_response.json_body
76
82
 
@@ -111,19 +117,28 @@ end
111
117
 
112
118
  describe 'GET /_ruote/processes/wfid' do
113
119
 
114
- it_has_an_engine
120
+ before(:each) do
121
+
122
+ prepare_engine_with_participants
123
+ end
124
+
125
+ after(:each) do
126
+
127
+ shutdown_and_purge_engine
128
+ end
115
129
 
116
130
  describe 'with a running process' do
117
131
 
118
132
  before(:each) do
119
- @wfid = launch_test_process
133
+
134
+ @wfid = launch_nada_process
120
135
  end
121
136
 
122
137
  it 'should give process information back (HTML)' do
123
138
 
124
139
  get "/_ruote/processes/#{@wfid}"
125
140
 
126
- last_response.status.should be(200)
141
+ last_response.status.should == 200
127
142
 
128
143
  last_response.should have_selector(
129
144
  'a[rel="http://ruote.rubyforge.org/rels.html#process_schedules"]')
@@ -133,7 +148,7 @@ describe 'GET /_ruote/processes/wfid' do
133
148
 
134
149
  get "/_ruote/processes/#{@wfid}.json"
135
150
 
136
- last_response.status.should be(200)
151
+ last_response.status.should == 200
137
152
 
138
153
  body = last_response.json_body
139
154
 
@@ -149,7 +164,7 @@ describe 'GET /_ruote/processes/wfid' do
149
164
 
150
165
  get '/_ruote/processes/foo'
151
166
 
152
- last_response.status.should be(404)
167
+ last_response.status.should == 404
153
168
 
154
169
  last_response.should match(/resource not found/)
155
170
  end
@@ -158,7 +173,7 @@ describe 'GET /_ruote/processes/wfid' do
158
173
 
159
174
  get '/_ruote/processes/foo.json'
160
175
 
161
- last_response.status.should be(404)
176
+ last_response.status.should == 404
162
177
 
163
178
  last_response.json_body.keys.should include('http_error')
164
179
 
@@ -171,13 +186,21 @@ end
171
186
 
172
187
  describe 'GET /_ruote/processes/new' do
173
188
 
174
- it_has_an_engine
189
+ before(:each) do
190
+
191
+ prepare_engine
192
+ end
193
+
194
+ after(:each) do
195
+
196
+ shutdown_and_purge_engine
197
+ end
175
198
 
176
199
  it 'should return a launch form' do
177
200
 
178
201
  get '/_ruote/processes/new'
179
202
 
180
- last_response.status.should be(200)
203
+ last_response.status.should == 200
181
204
 
182
205
  last_response.should_not have_selector('a', :content => 'as JSON')
183
206
  end
@@ -185,10 +208,14 @@ end
185
208
 
186
209
  describe 'POST /_ruote/processes' do
187
210
 
188
- it_has_an_engine
189
-
190
211
  before(:each) do
191
- engine.processes.should be_empty
212
+
213
+ prepare_engine
214
+ end
215
+
216
+ after(:each) do
217
+
218
+ shutdown_and_purge_engine
192
219
  end
193
220
 
194
221
  it 'should launch a valid process definition (JSON)' do
@@ -206,7 +233,7 @@ describe 'POST /_ruote/processes' do
206
233
  Rufus::Json.encode(params),
207
234
  { 'CONTENT_TYPE' => 'application/json' })
208
235
 
209
- last_response.status.should be(201)
236
+ last_response.status.should == 201
210
237
 
211
238
  last_response.json_body['launched'].should match(/[0-9a-z\-]+/)
212
239
 
@@ -231,7 +258,7 @@ describe 'POST /_ruote/processes' do
231
258
  Rufus::Json.encode(params),
232
259
  { 'CONTENT_TYPE' => 'application/json' })
233
260
 
234
- last_response.status.should be(201)
261
+ last_response.status.should == 201
235
262
  last_response.json_body['launched'].should match(/[0-9a-z\-]+/)
236
263
 
237
264
  sleep 0.5
@@ -307,7 +334,7 @@ describe 'POST /_ruote/processes' do
307
334
  Rufus::Json.encode(params),
308
335
  { 'CONTENT_TYPE' => 'application/json' })
309
336
 
310
- last_response.status.should be(400)
337
+ last_response.status.should == 400
311
338
  last_response.json_body.keys.should include('http_error')
312
339
  end
313
340
 
@@ -317,7 +344,7 @@ describe 'POST /_ruote/processes' do
317
344
 
318
345
  post '/_ruote/processes', params
319
346
 
320
- last_response.status.should be(400)
347
+ last_response.status.should == 400
321
348
  last_response.should match(/bad request/)
322
349
  end
323
350
 
@@ -325,35 +352,44 @@ end
325
352
 
326
353
  describe 'DELETE /_ruote/processes/wfid' do
327
354
 
328
- it_has_an_engine
355
+ before(:each) do
356
+
357
+ prepare_engine
358
+ end
359
+
360
+ after(:each) do
361
+
362
+ shutdown_and_purge_engine
363
+ end
329
364
 
330
365
  before(:each) do
331
366
 
332
- @wfid = launch_test_process do
333
- Ruote.process_definition :name => 'test' do
334
- sequence :on_cancel => 'bail_out' do
335
- echo 'done.'
336
- wait '1d'
337
- end
367
+ @wfid = RuoteKit.engine.launch(Ruote.process_definition do
368
+ sequence :on_cancel => 'bail_out' do
369
+ echo 'in'
370
+ wait '1d'
371
+ echo 'done.'
372
+ end
338
373
 
339
- define :name => 'bail_out' do
340
- echo 'bailout.'
341
- end
374
+ define :name => 'bail_out' do
375
+ echo 'bailout.'
342
376
  end
343
- end
377
+ end)
378
+
379
+ RuoteKit.engine.wait_for(3)
344
380
  end
345
381
 
346
382
  it 'should cancel processes (JSON)' do
347
383
 
348
384
  delete "/_ruote/processes/#{@wfid}.json"
349
385
 
350
- last_response.status.should be(200)
386
+ last_response.status.should == 200
351
387
 
352
388
  wait_for(@wfid)
353
389
 
354
390
  engine.process(@wfid).should be_nil
355
391
 
356
- @tracer.to_s.should == "done.\nbailout."
392
+ @tracer.to_s.should == "in\nbailout."
357
393
  end
358
394
 
359
395
  it 'should cancel processes (HMTL)' do
@@ -367,20 +403,20 @@ describe 'DELETE /_ruote/processes/wfid' do
367
403
 
368
404
  engine.process(@wfid).should be_nil
369
405
 
370
- @tracer.to_s.should == "done.\nbailout."
406
+ @tracer.to_s.should == "in\nbailout."
371
407
  end
372
408
 
373
409
  it 'should kill processes (JSON)' do
374
410
 
375
411
  delete "/_ruote/processes/#{@wfid}.json?_kill=1"
376
412
 
377
- last_response.status.should be(200)
413
+ last_response.status.should == 200
378
414
 
379
415
  wait_for(@wfid)
380
416
 
381
417
  engine.process(@wfid).should be_nil
382
418
 
383
- @tracer.to_s.should == 'done.'
419
+ @tracer.to_s.should == 'in'
384
420
  end
385
421
 
386
422
  it 'should kill processes (HTML)' do
@@ -394,7 +430,7 @@ describe 'DELETE /_ruote/processes/wfid' do
394
430
 
395
431
  engine.process(@wfid).should be_nil
396
432
 
397
- @tracer.to_s.should == 'done.'
433
+ @tracer.to_s.should == 'in'
398
434
  end
399
435
  end
400
436
 
@@ -1,14 +1,13 @@
1
- require 'spec_helper'
2
1
 
3
- undef :context if defined?(context)
2
+ require File.join(File.dirname(__FILE__), '..', 'spec_helper.rb')
4
3
 
5
4
 
6
5
  describe 'GET /_ruote/schedules' do
7
6
 
8
- it_has_an_engine
9
-
10
7
  before(:each) do
11
8
 
9
+ prepare_engine_with_participants
10
+
12
11
  @wfid0 = RuoteKit.engine.launch(Ruote.define do
13
12
  wait :for => '3d'
14
13
  end)
@@ -17,10 +16,18 @@ describe 'GET /_ruote/schedules' do
17
16
  alpha :timeout => '2d'
18
17
  end
19
18
  end)
19
+ @wfid2 = RuoteKit.engine.launch(Ruote.define do
20
+ nada
21
+ end)
20
22
 
21
23
  RuoteKit.engine.wait_for(:alpha)
22
24
  end
23
25
 
26
+ after(:each) do
27
+
28
+ shutdown_and_purge_engine
29
+ end
30
+
24
31
  it 'should list schedules (HTML)' do
25
32
 
26
33
  get '/_ruote/schedules'
@@ -29,6 +36,8 @@ describe 'GET /_ruote/schedules' do
29
36
 
30
37
  last_response.should have_selector(
31
38
  'a[rel="http://ruote.rubyforge.org/rels.html#process_schedules"]')
39
+
40
+ last_response.should contain('1 to 2 of 2 schedules')
32
41
  end
33
42
 
34
43
  it 'should list schedules (JSON)' do
@@ -51,19 +60,29 @@ describe 'GET /_ruote/schedules' do
51
60
  schedules.first['target'].should be_kind_of(Hash)
52
61
  schedules.first['owner'].should be_kind_of(Hash)
53
62
 
54
- wfid = [ @wfid0, @wfid1 ].sort.first
63
+ hrefs = schedules.collect { |s| s['links'].first['href'] }
64
+ prefixes = hrefs.collect { |h| h.split('!').first }.sort
65
+ suffixes = hrefs.collect { |h| h.split('!').last }.sort
55
66
 
56
- schedules.first['links'].first['href'].should ==
57
- "/_ruote/expressions/0_0!!#{wfid}"
67
+ hrefs = schedules.collect { |s|
68
+ s['links'].first['href']
69
+ }.collect { |h|
70
+ pieces = h.split('!')
71
+ pieces.first + '/' + pieces.last
72
+ }.sort
73
+
74
+ hrefs.should ==
75
+ [ "/_ruote/expressions/0_0/#{@wfid0}",
76
+ "/_ruote/expressions/0_0_0/#{@wfid1}" ]
58
77
  end
59
78
  end
60
79
 
61
80
  describe 'GET /_ruote/schedules/wfid' do
62
81
 
63
- it_has_an_engine
64
-
65
82
  before(:each) do
66
83
 
84
+ prepare_engine_with_participants
85
+
67
86
  @wfid0 = RuoteKit.engine.launch(Ruote.define do
68
87
  wait :for => '3d'
69
88
  end)
@@ -76,6 +95,11 @@ describe 'GET /_ruote/schedules/wfid' do
76
95
  RuoteKit.engine.wait_for(:alpha)
77
96
  end
78
97
 
98
+ after(:each) do
99
+
100
+ shutdown_and_purge_engine
101
+ end
102
+
79
103
  it 'should list schedules (HTML)' do
80
104
 
81
105
  get "/_ruote/schedules/#{@wfid1}"