ruote-kit 2.1.11 → 2.2.0.3

Sign up to get free protection for your applications and to get access to all the features.
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,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 workitem_count(from, to, of)
@@ -15,7 +13,15 @@ end
15
13
 
16
14
  describe 'GET /_ruote/workitems' do
17
15
 
18
- it_has_an_engine
16
+ before(:each) do
17
+
18
+ prepare_engine
19
+ end
20
+
21
+ after(:each) do
22
+
23
+ shutdown_and_purge_engine
24
+ end
19
25
 
20
26
  describe 'without any workitems' do
21
27
 
@@ -44,13 +50,16 @@ describe 'GET /_ruote/workitems' do
44
50
 
45
51
  before(:each) do
46
52
 
47
- @wfid = launch_test_process do
48
- Ruote.process_definition :name => 'test' do
49
- sequence do
50
- nada :activity => 'Work your magic'
51
- end
53
+ register_participants
54
+
55
+ @wfid = RuoteKit.engine.launch(Ruote.process_definition do
56
+ sequence do
57
+ nada :activity => 'Work your magic'
52
58
  end
53
- end
59
+ end)
60
+
61
+ RuoteKit.engine.wait_for(:nada)
62
+ RuoteKit.engine.wait_for(1)
54
63
  end
55
64
 
56
65
  it 'should have a list of workitems (HTML)' do
@@ -67,7 +76,7 @@ describe 'GET /_ruote/workitems' do
67
76
  last_response.should be_ok
68
77
  json = last_response.json_body
69
78
 
70
- json['workitems'].size.should be(1)
79
+ json['workitems'].size.should == 1
71
80
 
72
81
  wi = json['workitems'][0]
73
82
 
@@ -81,19 +90,31 @@ end
81
90
 
82
91
  describe 'GET /_ruote/workitems/wfid' do
83
92
 
84
- it_has_an_engine
93
+ before(:each) do
94
+
95
+ prepare_engine
96
+ end
97
+
98
+ after(:each) do
99
+
100
+ shutdown_and_purge_engine
101
+ end
85
102
 
86
103
  describe 'with workitems' do
87
104
 
88
105
  before(:each) do
89
- @wfid = launch_test_process do
90
- Ruote.process_definition :name => 'foo' do
91
- concurrence do
92
- nada :activity => 'This'
93
- nada :activity => 'Or that'
94
- end
106
+
107
+ register_participants
108
+
109
+ @wfid = RuoteKit.engine.launch(Ruote.process_definition do
110
+ concurrence do
111
+ nada :activity => 'This'
112
+ nada :activity => 'Or that'
95
113
  end
96
- end
114
+ end)
115
+
116
+ RuoteKit.engine.wait_for(:nada)
117
+ RuoteKit.engine.wait_for(1)
97
118
  end
98
119
 
99
120
  it 'should list the workitems (HTML)' do
@@ -145,55 +166,75 @@ describe 'GET /_ruote/workitems/wfid' do
145
166
  end
146
167
  end
147
168
 
148
- describe 'GET /_ruote/workitems/expid!!wfid' do
169
+ describe 'GET /_ruote/workitems/expid!subid!wfid' do
170
+
171
+ before(:each) do
172
+
173
+ prepare_engine_with_participants
174
+ end
149
175
 
150
- it_has_an_engine
176
+ after(:each) do
177
+
178
+ shutdown_and_purge_engine
179
+ end
151
180
 
152
181
  describe 'with a workitem' do
153
182
 
154
183
  before(:each) do
155
- @wfid = launch_test_process do
156
- Ruote.process_definition :name => 'foo' do
157
- sequence do
158
- nada :activity => 'Work your magic'
159
- end
184
+
185
+ @wfid = RuoteKit.engine.launch(Ruote.process_definition do
186
+ sequence do
187
+ nada :activity => 'Work your magic'
160
188
  end
161
- end
189
+ end)
162
190
 
163
- process = engine.process(@wfid)
164
- @nada_exp_id = '0_0_0' #process.expressions.last.fei.expid
191
+ RuoteKit.engine.wait_for(:nada)
165
192
 
166
- @nada_exp_id.should_not be_nil
193
+ @fei = engine.process(@wfid).expressions.last.fei
167
194
  end
168
195
 
169
196
  it 'should return it (HTML)' do
170
197
 
171
- get "/_ruote/workitems/#{@nada_exp_id}!!#{@wfid}"
198
+ get "/_ruote/workitems/#{@fei.sid}"
172
199
 
173
200
  last_response.should be_ok
174
201
  end
175
202
 
176
203
  it 'should return it (JSON)' do
177
204
 
178
- get "/_ruote/workitems/#{@nada_exp_id}!!#{@wfid}.json"
205
+ get "/_ruote/workitems/#{@fei.sid}.json"
179
206
 
180
207
  last_response.should be_ok
181
208
  end
182
209
 
183
210
  it 'should provide a workitem with the correct links (JSON)' do
184
211
 
185
- get "/_ruote/workitems/#{@nada_exp_id}!!#{@wfid}.json"
212
+ get "/_ruote/workitems/#{@fei.sid}.json"
186
213
 
187
- json = last_response.json_body
214
+ last_response.json_body['workitem']['links'].collect { |li|
215
+ li['rel']
216
+ }.should == %w[
217
+ self
218
+ http://ruote.rubyforge.org/rels.html#process
219
+ http://ruote.rubyforge.org/rels.html#process_expressions
220
+ http://ruote.rubyforge.org/rels.html#process_errors
221
+ ]
222
+ end
223
+
224
+ it 'should include an etag header (HTML)' do
225
+
226
+ get "/_ruote/workitems/#{@fei.sid}"
227
+
228
+ last_response.headers.should include('ETag')
229
+ last_response.headers['ETag'].should == "\"#{find_workitem(@wfid, @nada_exp_id).to_h['_rev'].to_s}\""
230
+ end
231
+
232
+ it 'should include an etag header (JSON)' do
188
233
 
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'] })
234
+ get "/_ruote/workitems/#{@fei.sid}.json"
235
+
236
+ last_response.headers.should include('ETag')
237
+ last_response.headers['ETag'].should == "\"#{find_workitem(@wfid, @nada_exp_id).to_h['_rev'].to_s}\""
197
238
  end
198
239
  end
199
240
 
@@ -219,39 +260,41 @@ end
219
260
 
220
261
  describe 'PUT /_ruote/workitems/fei' do
221
262
 
222
- it_has_an_engine
223
-
224
263
  before(:each) do
225
264
 
226
- @wfid = launch_test_process do
227
- Ruote.process_definition :name => 'foo' do
228
- sequence do
229
- nada :activity => 'Work your magic'
230
- echo '${f:foo}'
231
- end
265
+ prepare_engine_with_participants
266
+
267
+ @wfid = RuoteKit.engine.launch(Ruote.process_definition do
268
+ sequence do
269
+ nada :activity => 'Work your magic'
270
+ echo '${f:foo}'
232
271
  end
233
- end
272
+ end)
234
273
 
235
- process = engine.process(@wfid)
236
- @nada_exp_id = '0_0_0' #process.expressions.last.fei.expid
274
+ RuoteKit.engine.wait_for(:nada)
237
275
 
238
- @nada_exp_id.should_not be_nil
276
+ @fei = engine.process(@wfid).expressions.last.fei
239
277
 
240
278
  @fields = {
241
279
  'params' => { 'activity' => 'Work your magic' }, 'foo' => 'bar'
242
280
  }
243
281
  end
244
282
 
283
+ after(:each) do
284
+
285
+ shutdown_and_purge_engine
286
+ end
287
+
245
288
  it 'should update the workitem fields (HTML)' do
246
289
 
247
290
  put(
248
- "/_ruote/workitems/#{@nada_exp_id}!!#{@wfid}",
291
+ "/_ruote/workitems/#{@fei.expid}!#{@fei.subid}!#{@wfid}",
249
292
  :fields => Rufus::Json.encode(@fields))
250
293
 
251
294
  last_response.should be_redirect
252
295
 
253
296
  last_response['Location'].should ==
254
- "/_ruote/workitems/#{@nada_exp_id}!!#{@wfid}"
297
+ "/_ruote/workitems/#{@fei.expid}!#{@fei.subid}!#{@wfid}"
255
298
 
256
299
  find_workitem(@wfid, @nada_exp_id).fields.should == @fields
257
300
 
@@ -265,7 +308,7 @@ describe 'PUT /_ruote/workitems/fei' do
265
308
  params = { 'fields' => @fields }
266
309
 
267
310
  put(
268
- "/_ruote/workitems/#{@nada_exp_id}!!#{@wfid}.json",
311
+ "/_ruote/workitems/#{@fei.expid}!#{@fei.subid}!#{@wfid}.json",
269
312
  Rufus::Json.encode(params),
270
313
  { 'CONTENT_TYPE' => 'application/json' })
271
314
 
@@ -283,7 +326,7 @@ describe 'PUT /_ruote/workitems/fei' do
283
326
  params = { 'workitem' => { 'fields' => @fields } }
284
327
 
285
328
  put(
286
- "/_ruote/workitems/#{@nada_exp_id}!!#{@wfid}.json",
329
+ "/_ruote/workitems/#{@fei.expid}!#{@fei.subid}!#{@wfid}.json",
287
330
  Rufus::Json.encode(params),
288
331
  { 'CONTENT_TYPE' => 'application/json' })
289
332
 
@@ -297,7 +340,7 @@ describe 'PUT /_ruote/workitems/fei' do
297
340
  fields = Rufus::Json.encode(@fields)
298
341
 
299
342
  put(
300
- "/_ruote/workitems/#{@nada_exp_id}!!#{@wfid}",
343
+ "/_ruote/workitems/#{@fei.expid}!#{@fei.subid}!#{@wfid}",
301
344
  :fields => fields,
302
345
  :_proceed => '1')
303
346
 
@@ -318,7 +361,7 @@ describe 'PUT /_ruote/workitems/fei' do
318
361
  params = { 'fields' => @fields, '_proceed' => '1' }
319
362
 
320
363
  put(
321
- "/_ruote/workitems/#{@nada_exp_id}!!#{@wfid}.json",
364
+ "/_ruote/workitems/#{@fei.expid}!#{@fei.subid}!#{@wfid}.json",
322
365
  Rufus::Json.encode(params),
323
366
  { 'CONTENT_TYPE' => 'application/json' })
324
367
 
@@ -335,7 +378,9 @@ describe 'PUT /_ruote/workitems/fei' do
335
378
 
336
379
  it 'should 400 when passed bogus JSON fields (HTML)' do
337
380
 
338
- put "/_ruote/workitems/#{@nada_exp_id}!!#{@wfid}", :fields => '{"bogus"}'
381
+ put(
382
+ "/_ruote/workitems/#{@fei.expid}!#{@fei.subid}!#{@wfid}.json",
383
+ :fields => '{"bogus"}')
339
384
 
340
385
  last_response.status.should be(400)
341
386
  end
@@ -343,37 +388,83 @@ describe 'PUT /_ruote/workitems/fei' do
343
388
  it 'should 400 when passed bogus JSON fields (JSON)' do
344
389
 
345
390
  put(
346
- "/_ruote/workitems/#{@nada_exp_id}!!#{@wfid}.json",
391
+ "/_ruote/workitems/#{@fei.expid}!#{@fei.subid}!#{@wfid}.json",
347
392
  "{'bogus'}",
348
393
  { 'CONTENT_TYPE' => 'application/json' })
349
394
 
350
395
  last_response.status.should be(400)
351
396
  end
397
+
398
+ it 'should 412 if the etags do not match (HTML)' do
399
+
400
+ workitem = find_workitem(@wfid, @nada_exp_id)
401
+ old_rev = workitem.to_h['_rev']
402
+
403
+ workitem.fields = {'baz' => 'bar'}.merge!(@fields)
404
+ RuoteKit.engine.storage_participant.update(workitem)
405
+
406
+ put(
407
+ "/_ruote/workitems/#{@fei.expid}!#{@fei.subid}!#{@wfid}",
408
+ { :fields => Rufus::Json.encode(@fields) },
409
+ { 'HTTP_IF_MATCH' => ('"%s"' % old_rev) }
410
+ )
411
+
412
+ last_response.status.should be(412)
413
+ end
414
+
415
+ it 'should 412 if the etags do not match (JSON)' do
416
+
417
+ workitem = find_workitem(@wfid, @nada_exp_id)
418
+
419
+ old_rev = workitem.to_h['_rev']
420
+
421
+ workitem.fields = {'baz' => 'bar'}.merge!(@fields)
422
+ RuoteKit.engine.storage_participant.update(workitem)
423
+
424
+ params = { 'workitem' => { 'fields' => @fields } }
425
+
426
+ put(
427
+ "/_ruote/workitems/#{@fei.expid}!#{@fei.subid}!#{@wfid}.json",
428
+ Rufus::Json.encode(params),
429
+ {
430
+ 'CONTENT_TYPE' => 'application/json',
431
+ 'HTTP_IF_MATCH' => ('"%s"' % old_rev)
432
+ }
433
+ )
434
+
435
+ last_response.status.should be(412)
436
+ end
352
437
  end
353
438
 
354
439
  describe 'Filtering workitems' do
355
440
 
356
- it_has_an_engine
357
-
358
441
  before(:each) do
359
442
 
360
- @wfid = launch_test_process do
361
- Ruote.process_definition :name => 'test' do
362
- set 'foo' => 'bar'
363
- concurrence do
364
- sequence do
365
- set 'wands' => 101
366
- set 'hinkypinky' => 'honkytonky'
367
- jack :activity => 'Fetch a pale'
368
- end
369
- sequence do
370
- set 'hinkypinky' => 'honkytonky'
371
- jill :activity => 'Chase Jack'
372
- end
373
- well :activity => 'Ready water'
443
+ prepare_engine_with_participants
444
+
445
+ @wfid = RuoteKit.engine.launch(Ruote.process_definition do
446
+ set 'foo' => 'bar'
447
+ concurrence do
448
+ sequence do
449
+ set 'wands' => 101
450
+ set 'hinkypinky' => 'honkytonky'
451
+ jack :activity => 'Fetch a pale'
452
+ end
453
+ sequence do
454
+ set 'hinkypinky' => 'honkytonky'
455
+ jill :activity => 'Chase Jack'
374
456
  end
457
+ well :activity => 'Ready water'
375
458
  end
376
- end
459
+ end)
460
+
461
+ RuoteKit.engine.wait_for(:jack)
462
+ RuoteKit.engine.wait_for(1)
463
+ end
464
+
465
+ after(:each) do
466
+
467
+ shutdown_and_purge_engine
377
468
  end
378
469
 
379
470
  describe 'on participants' do
@@ -384,7 +475,7 @@ describe 'Filtering workitems' do
384
475
 
385
476
  last_response.should be_ok
386
477
 
387
- last_response.json_body['workitems'].size.should be(1)
478
+ last_response.json_body['workitems'].size.should == 1
388
479
  end
389
480
 
390
481
  it 'should narrow results down to a single participant (HTML)' do
@@ -406,7 +497,7 @@ describe 'Filtering workitems' do
406
497
 
407
498
  last_response.should be_ok
408
499
 
409
- last_response.json_body['workitems'].size.should be(2)
500
+ last_response.json_body['workitems'].size.should == 2
410
501
  end
411
502
 
412
503
  it 'should find workitems with fields set to a given value (HTML)' do
@@ -422,7 +513,7 @@ describe 'Filtering workitems' do
422
513
 
423
514
  last_response.should be_ok
424
515
 
425
- last_response.json_body['workitems'].size.should be(1)
516
+ last_response.json_body['workitems'].size.should == 1
426
517
  end
427
518
 
428
519
  it 'should respect JSON encoded filter vars (HTML)' do
@@ -438,7 +529,7 @@ describe 'Filtering workitems' do
438
529
 
439
530
  last_response.should be_ok
440
531
 
441
- last_response.json_body['workitems'].size.should be(1)
532
+ last_response.json_body['workitems'].size.should == 1
442
533
  end
443
534
 
444
535
  it "should combine search criteria by 'and' (HMTL)" do
data/spec/spec_helper.rb CHANGED
@@ -1,15 +1,13 @@
1
- $:.unshift(File.join(File.dirname(__FILE__), '..'))
1
+
2
+ HERE = File.dirname(__FILE__) unless defined?(HERE)
2
3
 
3
4
  ENV['RACK_ENV'] = 'test'
4
5
 
5
- require 'rubygems'
6
6
  require 'bundler'
7
7
  Bundler.setup(:default, :test)
8
8
 
9
- require 'spec'
10
- require 'spec/interop/test'
9
+ require 'rspec'
11
10
  require 'rack/test'
12
-
13
11
  require 'webrat'
14
12
 
15
13
  begin
@@ -23,21 +21,13 @@ rescue LoadError
23
21
  end
24
22
  end
25
23
 
26
- Test::Unit::TestCase.send :include, Rack::Test::Methods
27
-
28
- begin
29
- require File.join(File.dirname(__FILE__), '/../vendor/gems/environment')
30
- rescue LoadError
31
- end
32
- require File.join(File.dirname(__FILE__), '/../lib/ruote-kit')
33
-
34
- require 'ruote-kit/spec/ruote_helpers'
35
- require 'spec/it_has_an_engine'
36
-
24
+ require File.join(HERE, '../lib/ruote-kit')
37
25
  require 'ruote/log/test_logger'
38
26
 
27
+ Dir[File.join(HERE, 'support/**/*.rb')].each { |f| require(f) }
28
+
39
29
 
40
- Spec::Runner.configure do |config|
30
+ RSpec.configure do |config|
41
31
 
42
32
  # == Mock Framework
43
33
  #
@@ -48,49 +38,14 @@ Spec::Runner.configure do |config|
48
38
  # config.mock_with :flexmock
49
39
  # config.mock_with :rr
50
40
 
51
- # Include our helpers
52
- config.include Webrat::Matchers, :type => :views
53
- config.include RuoteKit::Spec::RuoteHelpers
41
+ config.include Webrat::Matchers
42
+ config.include Rack::Test::Methods
54
43
 
55
- def it_has_an_engine
56
- it_should_behave_like 'it has an engine'
57
- end
58
- def it_has_an_engine_with_no_participants
59
- it_should_behave_like 'it has an engine with no participants'
60
- end
44
+ config.include RenderHelper
45
+ config.include EngineHelper
61
46
 
62
47
  RuoteKit::Application.included_modules.each do |klass|
63
48
  config.include(klass) if klass.name =~ /RuoteKit::Helpers::\w+Helpers/
64
49
  end
65
50
  end
66
51
 
67
- def app
68
- RuoteKit::Application
69
- end
70
-
71
- def render(template, scope=nil, locals={}, &block)
72
- template = File.read(File.join(app.views, template.to_s))
73
- engine = Haml::Engine.new(template)
74
- engine.render(scope, locals, &block)
75
- end
76
-
77
- class Rack::MockResponse
78
-
79
- def json_body
80
- Rufus::Json.decode(body)
81
- end
82
-
83
- def json?
84
- begin
85
- json_body
86
- return true
87
- rescue
88
- return false
89
- end
90
- end
91
-
92
- def html?
93
- ! json?
94
- end
95
- end
96
-
@@ -0,0 +1,97 @@
1
+
2
+ class Tracer
3
+ def initialize
4
+ @trace = ''
5
+ end
6
+ def to_s
7
+ @trace.to_s.strip
8
+ end
9
+ def << s
10
+ @trace << s
11
+ end
12
+ def clear
13
+ @trace = ''
14
+ end
15
+ def puts s
16
+ @trace << "#{s}\n"
17
+ end
18
+ end
19
+
20
+
21
+ module EngineHelper
22
+
23
+ def prepare_engine
24
+
25
+ RuoteKit.engine =
26
+ Ruote::Engine.new(
27
+ Ruote::Worker.new(
28
+ Ruote::HashStorage.new))
29
+
30
+ @tracer = Tracer.new
31
+ RuoteKit.engine.add_service('tracer', @tracer)
32
+ end
33
+
34
+ def register_participants
35
+
36
+ RuoteKit.engine.register do
37
+ catchall Ruote::StorageParticipant
38
+ end
39
+ end
40
+
41
+ def prepare_engine_with_participants
42
+
43
+ prepare_engine
44
+ register_participants
45
+ end
46
+
47
+ def shutdown_and_purge_engine
48
+
49
+ return unless RuoteKit.engine
50
+
51
+ RuoteKit.engine.shutdown
52
+ RuoteKit.engine.storage.purge!
53
+ RuoteKit.engine = nil
54
+ end
55
+
56
+ def launch_nada_process
57
+
58
+ pdef = Ruote.process_definition :name => 'test' do
59
+ nada
60
+ end
61
+
62
+ wfid = RuoteKit.engine.launch(pdef)
63
+
64
+ RuoteKit.engine.wait_for(:nada)
65
+ RuoteKit.engine.wait_for(1)
66
+
67
+ wfid
68
+ end
69
+
70
+ def noisy(on = true)
71
+
72
+ RuoteKit.engine.noisy = on
73
+ end
74
+
75
+ def engine
76
+
77
+ RuoteKit.engine
78
+ end
79
+
80
+ def storage_participant
81
+
82
+ RuoteKit.engine.storage_participant
83
+ end
84
+
85
+ def find_workitem(wfid, expid)
86
+
87
+ RuoteKit.engine.storage_participant.by_wfid(wfid).first { |wi|
88
+ wi.fei.expid == expid
89
+ }
90
+ end
91
+
92
+ def wait_for(wfid)
93
+
94
+ RuoteKit.engine.wait_for(wfid)
95
+ end
96
+ end
97
+
@@ -0,0 +1,21 @@
1
+
2
+ class Rack::MockResponse
3
+
4
+ def json_body
5
+ Rufus::Json.decode(body)
6
+ end
7
+
8
+ def json?
9
+ begin
10
+ json_body
11
+ return true
12
+ rescue
13
+ return false
14
+ end
15
+ end
16
+
17
+ def html?
18
+ ! json?
19
+ end
20
+ end
21
+
@@ -0,0 +1,16 @@
1
+
2
+ module RenderHelper
3
+
4
+ def app
5
+
6
+ RuoteKit::Application
7
+ end
8
+
9
+ def render(template, scope=nil, locals={}, &block)
10
+
11
+ template = File.read(File.join(app.views, template.to_s))
12
+ engine = Haml::Engine.new(template)
13
+ engine.render(scope, locals, &block)
14
+ end
15
+ end
16
+
@@ -92,6 +92,7 @@ describe RuoteKit::Helpers::RenderHelpers do
92
92
  before(:each) do
93
93
  @resource = Object.new
94
94
  class << @resource
95
+ include RenderHelper
95
96
  attr_accessor :count, :skip, :limit, :request
96
97
  def to_html
97
98
  '<div>' + render('_pagination.html.haml', self) + '</div>'