ruote-kit 2.1.10 → 2.1.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. data/.gitignore +2 -0
  2. data/CHANGELOG.txt +10 -0
  3. data/Gemfile +21 -5
  4. data/LICENSE.txt +20 -0
  5. data/README.rdoc +132 -80
  6. data/Rakefile +4 -15
  7. data/TODO.txt +12 -0
  8. data/config.ru +22 -14
  9. data/lib/ruote-kit/application.rb +46 -22
  10. data/lib/ruote-kit/helpers/json_helpers.rb +280 -0
  11. data/lib/ruote-kit/helpers/link_helpers.rb +117 -0
  12. data/lib/ruote-kit/helpers/misc_helpers.rb +35 -0
  13. data/lib/ruote-kit/helpers/pagination_helpers.rb +30 -0
  14. data/lib/ruote-kit/helpers/render_helpers.rb +39 -92
  15. data/lib/ruote-kit/public/_ruote/images/favicon.ico +0 -0
  16. data/lib/ruote-kit/public/_ruote/images/ruote.png +0 -0
  17. data/lib/ruote-kit/public/_ruote/images/ruote_buttons.png +0 -0
  18. data/lib/ruote-kit/public/_ruote/javascripts/jquery-1.4.2.min.js +154 -0
  19. data/lib/ruote-kit/public/_ruote/javascripts/rk.js +40 -0
  20. data/lib/ruote-kit/public/_ruote/javascripts/ruote-fluo-editor.js +548 -0
  21. data/lib/ruote-kit/public/_ruote/javascripts/ruote-fluo.js +32 -1
  22. data/lib/ruote-kit/public/_ruote/stylesheets/reset.css +53 -0
  23. data/lib/ruote-kit/public/_ruote/stylesheets/rk.css +355 -16
  24. data/lib/ruote-kit/public/_ruote/stylesheets/ruote-fluo-editor.css +108 -0
  25. data/lib/ruote-kit/resources/errors.rb +46 -43
  26. data/lib/ruote-kit/resources/expressions.rb +92 -35
  27. data/lib/ruote-kit/resources/participants.rb +53 -0
  28. data/lib/ruote-kit/resources/processes.rb +68 -36
  29. data/lib/ruote-kit/resources/schedules.rb +27 -0
  30. data/lib/ruote-kit/resources/workitems.rb +93 -31
  31. data/lib/ruote-kit/spec/ruote_helpers.rb +25 -16
  32. data/lib/ruote-kit/version.rb +3 -1
  33. data/lib/ruote-kit/views/_pagination.html.haml +38 -0
  34. data/lib/ruote-kit/views/_tree_editor.html.haml +52 -0
  35. data/lib/ruote-kit/views/error.html.haml +69 -0
  36. data/lib/ruote-kit/views/errors.html.haml +28 -12
  37. data/lib/ruote-kit/views/expression.html.haml +161 -30
  38. data/lib/ruote-kit/views/expressions.html.haml +26 -21
  39. data/lib/ruote-kit/views/http_error.html.haml +11 -0
  40. data/lib/ruote-kit/views/index.html.haml +4 -0
  41. data/lib/ruote-kit/views/layout.html.haml +52 -32
  42. data/lib/ruote-kit/views/participants.html.haml +79 -0
  43. data/lib/ruote-kit/views/process.html.haml +109 -42
  44. data/lib/ruote-kit/views/process_launched.html.haml +6 -2
  45. data/lib/ruote-kit/views/processes.html.haml +55 -24
  46. data/lib/ruote-kit/views/processes_new.html.haml +36 -0
  47. data/lib/ruote-kit/views/schedules.html.haml +42 -0
  48. data/lib/ruote-kit/views/workitem.html.haml +83 -29
  49. data/lib/ruote-kit/views/workitems.html.haml +42 -19
  50. data/lib/ruote-kit.rb +17 -88
  51. data/ruote-kit.gemspec +68 -80
  52. data/spec/it_has_an_engine.rb +69 -0
  53. data/spec/resources/errors_spec.rb +198 -270
  54. data/spec/resources/expressions_spec.rb +308 -52
  55. data/spec/resources/index_spec.rb +28 -16
  56. data/spec/resources/participants_spec.rb +102 -0
  57. data/spec/resources/processes_spec.rb +218 -104
  58. data/spec/resources/schedules_spec.rb +97 -0
  59. data/spec/resources/workitems_spec.rb +195 -100
  60. data/spec/ruote-kit_configure_spec.rb +32 -75
  61. data/spec/spec.opts +0 -1
  62. data/spec/spec_helper.rb +31 -92
  63. data/spec/webapp_helpers_spec.rb +309 -0
  64. metadata +87 -152
  65. data/lib/ruote-kit/configuration.rb +0 -83
  66. data/lib/ruote-kit/helpers/engine_helpers.rb +0 -24
  67. data/lib/ruote-kit/helpers/form_helpers.rb +0 -11
  68. data/lib/ruote-kit/helpers/launch_item_parser.rb +0 -59
  69. data/lib/ruote-kit/helpers/navigation_helpers.rb +0 -54
  70. data/lib/ruote-kit/helpers.rb +0 -9
  71. data/lib/ruote-kit/public/_ruote/images/bg.gif +0 -0
  72. data/lib/ruote-kit/public/_ruote/images/bg_button_left.gif +0 -0
  73. data/lib/ruote-kit/public/_ruote/images/bg_button_left_cancel.gif +0 -0
  74. data/lib/ruote-kit/public/_ruote/images/bg_button_left_submit.gif +0 -0
  75. data/lib/ruote-kit/public/_ruote/images/bg_button_right.gif +0 -0
  76. data/lib/ruote-kit/public/_ruote/javascripts/SimplyButtons.js +0 -191
  77. data/lib/ruote-kit/public/_ruote/javascripts/fluo-dial.js +0 -149
  78. data/lib/ruote-kit/public/_ruote/stylesheets/SimplyButtons.css +0 -226
  79. data/lib/ruote-kit/public/_ruote/stylesheets/base.css +0 -336
  80. data/lib/ruote-kit/public/_ruote/stylesheets/style.css +0 -393
  81. data/lib/ruote-kit/views/launch_process.html.haml +0 -19
  82. data/lib/ruote-kit/views/process_failed_to_launch.html.haml +0 -7
  83. data/lib/ruote-kit/views/resource_not_found.html.haml +0 -7
  84. data/spec/helpers/render_helpers_spec.rb +0 -214
  85. data/spec/ruote-kit_spec.rb +0 -4
  86. data/spec/views/expressions.html.haml_spec.rb +0 -31
  87. data/spec/views/launch_process.html.haml_spec.rb +0 -22
  88. data/spec/views/process.html.haml_spec.rb +0 -17
  89. data/spec/views/process_launched.html.haml_spec.rb +0 -16
  90. data/spec/views/processes.html.haml_spec.rb +0 -31
  91. data/spec/views/workitems.html.haml_spec.rb +0 -69
@@ -1,19 +1,36 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
1
+
2
+ require 'spec_helper'
2
3
 
3
4
  undef :context if defined?(context)
4
5
 
5
- describe "GET /_ruote/workitems", :type => :with_engine do
6
6
 
7
- describe "without any workitems" do
8
- it "should report no workitems (HTML)" do
9
- get "/_ruote/workitems"
7
+ def workitem_count(from, to, of)
8
+ [
9
+ from, 'to', to, 'of', of, 'workitems'
10
+ ].collect { |e|
11
+ e.to_s
12
+ }.join("\n ")
13
+ end
14
+
15
+
16
+ describe 'GET /_ruote/workitems' do
17
+
18
+ it_has_an_engine
19
+
20
+ describe 'without any workitems' do
21
+
22
+ it 'should report no workitems (HTML)' do
23
+
24
+ get '/_ruote/workitems'
10
25
 
11
26
  last_response.should be_ok
12
- last_response.should match(/No workitems are currently available/)
27
+
28
+ last_response.should match(workitem_count(0, 0, 0))
13
29
  end
14
30
 
15
- it "should report no workitems (JSON)" do
16
- get "/_ruote/workitems.json"
31
+ it 'should report no workitems (JSON)' do
32
+
33
+ get '/_ruote/workitems.json'
17
34
 
18
35
  last_response.should be_ok
19
36
  json = last_response.json_body
@@ -23,8 +40,10 @@ describe "GET /_ruote/workitems", :type => :with_engine do
23
40
  end
24
41
  end
25
42
 
26
- describe "with workitems" do
43
+ describe 'with workitems' do
44
+
27
45
  before(:each) do
46
+
28
47
  @wfid = launch_test_process do
29
48
  Ruote.process_definition :name => 'test' do
30
49
  sequence do
@@ -34,15 +53,16 @@ describe "GET /_ruote/workitems", :type => :with_engine do
34
53
  end
35
54
  end
36
55
 
37
- it "should have a list of workitems (HTML)" do
38
- get "/_ruote/workitems"
56
+ it 'should have a list of workitems (HTML)' do
39
57
 
40
- last_response.should be_ok
41
- last_response.should match(/1 workitem available/)
58
+ get '/_ruote/workitems'
59
+
60
+ last_response.should match(workitem_count(1, 1, 1))
42
61
  end
43
62
 
44
- it "should have a list of workitems (JSON)" do
45
- get "/_ruote/workitems.json"
63
+ it 'should have a list of workitems (JSON)' do
64
+
65
+ get '/_ruote/workitems.json'
46
66
 
47
67
  last_response.should be_ok
48
68
  json = last_response.json_body
@@ -52,16 +72,19 @@ describe "GET /_ruote/workitems", :type => :with_engine do
52
72
  wi = json['workitems'][0]
53
73
 
54
74
  wi.keys.should include('fei', 'participant_name', 'fields')
55
- wi['fei']['wfid'].should == @wfid
75
+ wi['wfid'].should == @wfid
56
76
  wi['participant_name'].should == 'nada'
57
77
  wi['fields']['params']['activity'].should == 'Work your magic'
58
78
  end
59
79
  end
60
80
  end
61
81
 
62
- describe "GET /_ruote/workitems/wfid", :type => :with_engine do
82
+ describe 'GET /_ruote/workitems/wfid' do
83
+
84
+ it_has_an_engine
85
+
86
+ describe 'with workitems' do
63
87
 
64
- describe "with workitems" do
65
88
  before(:each) do
66
89
  @wfid = launch_test_process do
67
90
  Ruote.process_definition :name => 'foo' do
@@ -73,14 +96,18 @@ describe "GET /_ruote/workitems/wfid", :type => :with_engine do
73
96
  end
74
97
  end
75
98
 
76
- it "should list the workitems (HTML)" do
99
+ it 'should list the workitems (HTML)' do
100
+
77
101
  get "/_ruote/workitems/#{@wfid}"
78
102
 
79
103
  last_response.should be_ok
80
- last_response.should match(/2 workitems available for #{@wfid}/)
104
+
105
+ last_response.should have_selector(
106
+ 'div#pagination', :content => '2 workitems')
81
107
  end
82
108
 
83
- it "should list the workitems (JSON)" do
109
+ it 'should list the workitems (JSON)' do
110
+
84
111
  get "/_ruote/workitems/#{@wfid}.json"
85
112
 
86
113
  last_response.should be_ok
@@ -92,16 +119,21 @@ describe "GET /_ruote/workitems/wfid", :type => :with_engine do
92
119
  end
93
120
  end
94
121
 
95
- describe "without workitems" do
96
- it "should report no workitems (HTML)" do
97
- get "/_ruote/workitems/foo"
122
+ describe 'without workitems' do
123
+
124
+ it 'should report no workitems (HTML)' do
125
+
126
+ get '/_ruote/workitems/foo'
98
127
 
99
128
  last_response.should be_ok
100
- last_response.should match(/No workitems are currently available for foo/)
129
+
130
+ last_response.should have_selector(
131
+ 'div#pagination', :content => '0 workitems')
101
132
  end
102
133
 
103
- it "should report an empty list (JSON)" do
104
- get "/_ruote/workitems/foo.json"
134
+ it 'should report an empty list (JSON)' do
135
+
136
+ get '/_ruote/workitems/foo.json'
105
137
 
106
138
  last_response.should be_ok
107
139
 
@@ -113,9 +145,12 @@ describe "GET /_ruote/workitems/wfid", :type => :with_engine do
113
145
  end
114
146
  end
115
147
 
116
- describe "GET /_ruote/workitems/wfid/expid", :type => :with_engine do
148
+ describe 'GET /_ruote/workitems/expid!!wfid' do
149
+
150
+ it_has_an_engine
151
+
152
+ describe 'with a workitem' do
117
153
 
118
- describe "with a workitem" do
119
154
  before(:each) do
120
155
  @wfid = launch_test_process do
121
156
  Ruote.process_definition :name => 'foo' do
@@ -125,35 +160,56 @@ describe "GET /_ruote/workitems/wfid/expid", :type => :with_engine do
125
160
  end
126
161
  end
127
162
 
128
- process = engine.process( @wfid )
129
- @nada_exp_id = "0_0_0" #process.expressions.last.fei.expid
163
+ process = engine.process(@wfid)
164
+ @nada_exp_id = '0_0_0' #process.expressions.last.fei.expid
130
165
 
131
166
  @nada_exp_id.should_not be_nil
132
167
  end
133
168
 
134
- it "should return it (HTML)" do
135
- get "/_ruote/workitems/#{@wfid}/#{@nada_exp_id}"
169
+ it 'should return it (HTML)' do
170
+
171
+ get "/_ruote/workitems/#{@nada_exp_id}!!#{@wfid}"
136
172
 
137
173
  last_response.should be_ok
138
174
  end
139
175
 
140
- it "should return it (JSON)" do
141
- get "/_ruote/workitems/#{@wfid}/#{@nada_exp_id}.json"
176
+ it 'should return it (JSON)' do
177
+
178
+ get "/_ruote/workitems/#{@nada_exp_id}!!#{@wfid}.json"
142
179
 
143
180
  last_response.should be_ok
144
181
  end
182
+
183
+ it 'should provide a workitem with the correct links (JSON)' do
184
+
185
+ get "/_ruote/workitems/#{@nada_exp_id}!!#{@wfid}.json"
186
+
187
+ json = last_response.json_body
188
+
189
+ assert_equal(
190
+ %w[
191
+ self
192
+ http://ruote.rubyforge.org/rels.html#process
193
+ http://ruote.rubyforge.org/rels.html#process_expressions
194
+ http://ruote.rubyforge.org/rels.html#process_errors
195
+ ],
196
+ json['workitem']['links'].collect { |li| li['rel'] })
197
+ end
145
198
  end
146
199
 
147
- describe "without a workitem" do
148
- it "should return a 404 (HTML)" do
149
- get "/_ruote/workitems/foo/bar"
200
+ describe 'without a workitem' do
201
+
202
+ it 'should return a 404 (HTML)' do
203
+
204
+ get '/_ruote/workitems/foo/bar'
150
205
 
151
206
  last_response.should_not be_ok
152
207
  last_response.status.should be(404)
153
208
  end
154
209
 
155
- it "should return a 404 (JSON)" do
156
- get "/_ruote/workitems/foo/bar.json"
210
+ it 'should return a 404 (JSON)' do
211
+
212
+ get '/_ruote/workitems/foo/bar.json'
157
213
 
158
214
  last_response.should_not be_ok
159
215
  last_response.status.should be(404)
@@ -161,75 +217,89 @@ describe "GET /_ruote/workitems/wfid/expid", :type => :with_engine do
161
217
  end
162
218
  end
163
219
 
164
- describe "PUT /_ruote/workitems/X-Y", :type => :with_engine do
220
+ describe 'PUT /_ruote/workitems/fei' do
221
+
222
+ it_has_an_engine
165
223
 
166
224
  before(:each) do
225
+
167
226
  @wfid = launch_test_process do
168
227
  Ruote.process_definition :name => 'foo' do
169
228
  sequence do
170
229
  nada :activity => 'Work your magic'
171
- echo "${f:foo}"
230
+ echo '${f:foo}'
172
231
  end
173
232
  end
174
233
  end
175
234
 
176
- process = engine.process( @wfid )
177
- @nada_exp_id = "0_0_0" #process.expressions.last.fei.expid
235
+ process = engine.process(@wfid)
236
+ @nada_exp_id = '0_0_0' #process.expressions.last.fei.expid
178
237
 
179
238
  @nada_exp_id.should_not be_nil
180
- end
181
239
 
182
- it "should update the workitem fields (HTML)" do
183
- fields = {
184
- "params" => {
185
- "activity" => "Work your magic",
186
- },
187
- "foo" => "bar"
240
+ @fields = {
241
+ 'params' => { 'activity' => 'Work your magic' }, 'foo' => 'bar'
188
242
  }
243
+ end
244
+
245
+ it 'should update the workitem fields (HTML)' do
189
246
 
190
- put "/_ruote/workitems/#{@wfid}/#{@nada_exp_id}", :fields => fields.to_json
247
+ put(
248
+ "/_ruote/workitems/#{@nada_exp_id}!!#{@wfid}",
249
+ :fields => Rufus::Json.encode(@fields))
191
250
 
192
251
  last_response.should be_redirect
193
- last_response['Location'].should == "/_ruote/workitems/#{@wfid}/#{@nada_exp_id}"
194
252
 
195
- find_workitem( @wfid, @nada_exp_id ).fields.should == fields
253
+ last_response['Location'].should ==
254
+ "/_ruote/workitems/#{@nada_exp_id}!!#{@wfid}"
255
+
256
+ find_workitem(@wfid, @nada_exp_id).fields.should == @fields
196
257
 
197
258
  sleep 0.4
198
259
 
199
- @tracer.to_s.should == ""
260
+ @tracer.to_s.should == ''
200
261
  end
201
262
 
202
- it "should update the workitem fields (JSON)" do
203
- fields = {
204
- "params" => {
205
- "activity" => "Work your magic",
206
- },
207
- "foo" => "bar"
208
- }
209
- params = {
210
- "fields" => fields
211
- }
263
+ it 'should update the workitem fields (JSON)' do
264
+
265
+ params = { 'fields' => @fields }
212
266
 
213
- put "/_ruote/workitems/#{@wfid}/#{@nada_exp_id}.json", Rufus::Json.encode(params), { 'CONTENT_TYPE' => 'application/json' }
267
+ put(
268
+ "/_ruote/workitems/#{@nada_exp_id}!!#{@wfid}.json",
269
+ Rufus::Json.encode(params),
270
+ { 'CONTENT_TYPE' => 'application/json' })
214
271
 
215
272
  last_response.should be_ok
216
273
 
217
- find_workitem( @wfid, @nada_exp_id ).fields.should == fields
274
+ find_workitem(@wfid, @nada_exp_id).fields.should == @fields
218
275
 
219
276
  sleep 0.4
220
277
 
221
- @tracer.to_s.should == ""
278
+ @tracer.to_s.should == ''
279
+ end
280
+
281
+ it 'should update the fields when passed {"workitem":...} (JSON)' do
282
+
283
+ params = { 'workitem' => { 'fields' => @fields } }
284
+
285
+ put(
286
+ "/_ruote/workitems/#{@nada_exp_id}!!#{@wfid}.json",
287
+ Rufus::Json.encode(params),
288
+ { 'CONTENT_TYPE' => 'application/json' })
289
+
290
+ last_response.should be_ok
291
+
292
+ find_workitem(@wfid, @nada_exp_id).fields.should == @fields
222
293
  end
223
294
 
224
- it "should reply to the engine (HTML)" do
225
- fields = Rufus::Json.encode({
226
- "params" => {
227
- "activity" => "Work your magic",
228
- },
229
- "foo" => "bar"
230
- })
295
+ it 'should reply to the engine (HTML)' do
296
+
297
+ fields = Rufus::Json.encode(@fields)
231
298
 
232
- put "/_ruote/workitems/#{@wfid}/#{@nada_exp_id}", :fields => fields, :_proceed => '1'
299
+ put(
300
+ "/_ruote/workitems/#{@nada_exp_id}!!#{@wfid}",
301
+ :fields => fields,
302
+ :_proceed => '1')
233
303
 
234
304
  last_response.should be_redirect
235
305
  last_response['Location'].should == "/_ruote/workitems/#{@wfid}"
@@ -240,22 +310,17 @@ describe "PUT /_ruote/workitems/X-Y", :type => :with_engine do
240
310
  #])
241
311
  sleep 0.5
242
312
 
243
- @tracer.to_s.should == "bar"
313
+ @tracer.to_s.should == 'bar'
244
314
  end
245
315
 
246
- it "should reply to the engine (JSON)" do
247
- fields = {
248
- "params" => {
249
- "activity" => "Work your magic",
250
- },
251
- "foo" => "bar"
252
- }
253
- params = {
254
- "fields" => fields,
255
- "_proceed" => "1"
256
- }
316
+ it 'should reply to the engine (JSON)' do
317
+
318
+ params = { 'fields' => @fields, '_proceed' => '1' }
257
319
 
258
- put "/_ruote/workitems/#{@wfid}/#{@nada_exp_id}.json", params.to_json, { 'CONTENT_TYPE' => 'application/json' }
320
+ put(
321
+ "/_ruote/workitems/#{@nada_exp_id}!!#{@wfid}.json",
322
+ Rufus::Json.encode(params),
323
+ { 'CONTENT_TYPE' => 'application/json' })
259
324
 
260
325
  last_response.should be_ok
261
326
 
@@ -265,13 +330,33 @@ describe "PUT /_ruote/workitems/X-Y", :type => :with_engine do
265
330
  #])
266
331
  sleep 0.5
267
332
 
268
- @tracer.to_s.should == "bar"
333
+ @tracer.to_s.should == 'bar'
334
+ end
335
+
336
+ it 'should 400 when passed bogus JSON fields (HTML)' do
337
+
338
+ put "/_ruote/workitems/#{@nada_exp_id}!!#{@wfid}", :fields => '{"bogus"}'
339
+
340
+ last_response.status.should be(400)
341
+ end
342
+
343
+ it 'should 400 when passed bogus JSON fields (JSON)' do
344
+
345
+ put(
346
+ "/_ruote/workitems/#{@nada_exp_id}!!#{@wfid}.json",
347
+ "{'bogus'}",
348
+ { 'CONTENT_TYPE' => 'application/json' })
349
+
350
+ last_response.status.should be(400)
269
351
  end
270
352
  end
271
353
 
272
- describe "Filtering workitems", :type => :with_engine do
354
+ describe 'Filtering workitems' do
355
+
356
+ it_has_an_engine
273
357
 
274
358
  before(:each) do
359
+
275
360
  @wfid = launch_test_process do
276
361
  Ruote.process_definition :name => 'test' do
277
362
  set 'foo' => 'bar'
@@ -291,9 +376,10 @@ describe "Filtering workitems", :type => :with_engine do
291
376
  end
292
377
  end
293
378
 
294
- describe "on participants" do
379
+ describe 'on participants' do
380
+
381
+ it 'should narrow results down to a single participant (JSON)' do
295
382
 
296
- it "should narrow results down to a single participant (JSON)" do
297
383
  get '/_ruote/workitems.json', :participant => 'jack'
298
384
 
299
385
  last_response.should be_ok
@@ -301,17 +387,21 @@ describe "Filtering workitems", :type => :with_engine do
301
387
  last_response.json_body['workitems'].size.should be(1)
302
388
  end
303
389
 
304
- it "should narrow results down to a single participant (HTML)" do
390
+ it 'should narrow results down to a single participant (HTML)' do
391
+
305
392
  get '/_ruote/workitems', :participant => 'jack'
306
393
 
307
394
  last_response.should be_ok
395
+
396
+ last_response.should match(workitem_count(1, 3, 3))
308
397
  end
309
398
 
310
399
  end
311
400
 
312
- describe "on field values" do
401
+ describe 'on field values' do
402
+
403
+ it 'should find workitems with fields set to a given value (JSON)' do
313
404
 
314
- it "should find worktitems with fields set to a given value (JSON)" do
315
405
  get '/_ruote/workitems.json', :hinkypinky => 'honkytonky'
316
406
 
317
407
  last_response.should be_ok
@@ -319,13 +409,15 @@ describe "Filtering workitems", :type => :with_engine do
319
409
  last_response.json_body['workitems'].size.should be(2)
320
410
  end
321
411
 
322
- it "should find worktitems with fields set to a given value (HTML)" do
412
+ it 'should find workitems with fields set to a given value (HTML)' do
413
+
323
414
  get '/_ruote/workitems', :hinkypinky => 'honkytonky'
324
415
 
325
416
  last_response.should be_ok
326
417
  end
327
418
 
328
- it "should respect JSON encoded filter vars (JSON)" do
419
+ it 'should respect JSON encoded filter vars (JSON)' do
420
+
329
421
  get '/_ruote/workitems.json', :wands => 101
330
422
 
331
423
  last_response.should be_ok
@@ -333,13 +425,15 @@ describe "Filtering workitems", :type => :with_engine do
333
425
  last_response.json_body['workitems'].size.should be(1)
334
426
  end
335
427
 
336
- it "should respect JSON encoded filter vars (HTML)" do
428
+ it 'should respect JSON encoded filter vars (HTML)' do
429
+
337
430
  get '/_ruote/workitems', :wands => 101
338
431
 
339
432
  last_response.should be_ok
340
433
  end
341
434
 
342
435
  it "should combine search criteria by 'and' (JSON)" do
436
+
343
437
  get '/_ruote/workitems.json', :hinkypinky => 'honkytonky', :wands => 101
344
438
 
345
439
  last_response.should be_ok
@@ -348,10 +442,11 @@ describe "Filtering workitems", :type => :with_engine do
348
442
  end
349
443
 
350
444
  it "should combine search criteria by 'and' (HMTL)" do
445
+
351
446
  get '/_ruote/workitems', :hinkypinky => 'honkytonky', :wands => 101
352
447
 
353
448
  last_response.should be_ok
354
449
  end
355
-
356
450
  end
357
451
  end
452
+
@@ -3,97 +3,54 @@ require File.join(File.dirname(__FILE__), 'spec_helper.rb')
3
3
 
4
4
  undef :context if defined?(context)
5
5
 
6
- class MyCustomStorage
7
- attr_reader :opts
8
- def initialize (opts)
9
- @opts = opts
10
- end
11
- end
12
-
13
- class MyParticipant
14
- end
15
6
 
16
7
  describe RuoteKit do
17
8
 
18
- describe 'configure' do
9
+ # describe 'run_worker' do
10
+ #
11
+ # before(:each) do
12
+ # RuoteKit.run_worker(Ruote::HashStorage.new)
13
+ # end
14
+ #
15
+ # it 'should instantiate an engine' do
16
+ # RuoteKit.engine.should_not == nil
17
+ # end
18
+ #
19
+ # it 'should instantiate an engine with a worker' do
20
+ # RuoteKit.engine.worker.should_not == nil
21
+ # end
22
+ #
23
+ # it 'should instantiate an engine bound to a storage' do
24
+ # RuoteKit.engine.storage.class.should == Ruote::HashStorage
25
+ # end
26
+ # end
27
+
28
+ describe 'bind_engine' do
19
29
 
20
30
  before(:each) do
21
- # nothing
22
- end
23
-
24
- it 'should default to :transient' do
25
-
26
- RuoteKit.configuration.mode.should == :transient
27
- end
28
- end
29
-
30
- describe 'configure with a custom storage' do
31
-
32
- before(:each) do
33
-
34
- RuoteKit.configure do |conf|
35
- #require 'path/to/my_custom_storage'
36
- conf.set_storage( MyCustomStorage, :a => 'A', :b => 'B' )
37
- conf.run_engine = false
38
- end
31
+ RuoteKit.bind_engine(Ruote::HashStorage.new)
39
32
  end
40
33
 
41
- after(:each) do
42
- RuoteKit.reset_configuration!
34
+ it 'should instantiate an engine' do
35
+ RuoteKit.engine.should_not == nil
43
36
  end
44
37
 
45
- it 'should advertise mode as :custom' do
46
-
47
- RuoteKit.configuration.mode.should == :custom
38
+ it 'should instantiate an engine without a worker' do
39
+ RuoteKit.engine.worker.should == nil
48
40
  end
49
41
 
50
- it 'should return an instance of the customer storage' do
51
-
52
- si = RuoteKit.configuration.storage_instance
53
-
54
- si.class.should == MyCustomStorage
55
- si.opts.should == { :a => 'A', :b => 'B' }
42
+ it 'should instantiate an engine bound to a storage' do
43
+ RuoteKit.engine.storage.class.should == Ruote::HashStorage
56
44
  end
57
45
  end
58
46
 
59
- describe 'register participants' do
60
-
61
- require 'ruote/participant'
62
-
63
- describe 'custom participant' do
64
- RuoteKit.configure do |conf|
65
- conf.register do
66
- participant 'al', MyParticipant
67
- end
68
- end
69
-
70
- RuoteKit.engine.context.plist.names.should == ['^al$']
71
- end
47
+ describe 'direct engine setting' do
72
48
 
73
- describe 'catchall participant' do
74
- RuoteKit.configure do |conf|
75
- conf.register do
76
- catchall MyParticipant
77
- end
78
- end
79
-
80
- RuoteKit.engine.context.plist.names.should == [ '^.+$' ]
81
- end
82
-
83
- describe 'catchall participant without any options' do
84
- require 'ruote/part/storage_participant'
85
-
86
- RuoteKit.configure do |conf|
87
- conf.register do
88
- catchall
89
- end
90
- end
91
-
92
- RuoteKit.engine.context.plist.lookup('.+').instance_of?(Ruote::StorageParticipant).should == true
93
- end
49
+ # stupid illustrative spec
94
50
 
95
- after do
96
- RuoteKit.reset_configuration!
51
+ it 'should comply' do
52
+ RuoteKit.engine = Ruote::Engine.new(Ruote::HashStorage.new)
53
+ RuoteKit.engine.should_not == nil
97
54
  end
98
55
  end
99
56
  end
data/spec/spec.opts CHANGED
@@ -1,2 +1 @@
1
1
  --colour
2
- --debugger