ruote-kit 2.1.4.1 → 2.1.7
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.
- data/.gitignore +1 -2
- data/Gemfile +10 -1
- data/README.rdoc +53 -10
- data/Rakefile +17 -5
- data/config.ru +15 -1
- data/lib/ruote-kit/application.rb +10 -5
- data/lib/ruote-kit/configuration.rb +34 -3
- data/lib/ruote-kit/helpers/engine_helpers.rb +3 -3
- data/lib/ruote-kit/helpers/render_helpers.rb +10 -1
- data/lib/ruote-kit/resources/processes.rb +10 -4
- data/lib/ruote-kit/resources/workitems.rb +6 -4
- data/lib/ruote-kit/spec/ruote_helpers.rb +3 -3
- data/lib/ruote-kit/version.rb +11 -0
- data/lib/ruote-kit/views/expression.html.haml +1 -1
- data/lib/ruote-kit/views/expressions.html.haml +1 -1
- data/lib/ruote-kit/views/process.html.haml +1 -1
- data/lib/ruote-kit/views/process_failed_to_launch.html.haml +7 -0
- data/lib/ruote-kit/views/process_launched.html.haml +6 -0
- data/lib/ruote-kit.rb +21 -9
- data/ruote-kit.gemspec +32 -27
- data/spec/helpers/render_helpers_spec.rb +5 -2
- data/spec/resources/expressions_spec.rb +8 -4
- data/spec/resources/index_spec.rb +4 -2
- data/spec/resources/processes_spec.rb +37 -11
- data/spec/resources/workitems_spec.rb +12 -5
- data/spec/ruote-kit_configure_spec.rb +100 -0
- data/spec/spec_helper.rb +15 -9
- data/spec/views/expressions.html.haml_spec.rb +31 -0
- data/spec/views/launch_process.html.haml_spec.rb +2 -1
- data/spec/views/process.html.haml_spec.rb +2 -1
- data/spec/views/process_launched.html.haml_spec.rb +16 -0
- data/spec/views/processes.html.haml_spec.rb +2 -1
- data/spec/views/workitems.html.haml_spec.rb +3 -2
- metadata +58 -25
- data/lib/ruote-kit/vendor/sinatra-respond_to/LICENSE +0 -21
- data/lib/ruote-kit/vendor/sinatra-respond_to/README.markdown +0 -102
- data/lib/ruote-kit/vendor/sinatra-respond_to/Rakefile +0 -30
- data/lib/ruote-kit/vendor/sinatra-respond_to/VERSION.yml +0 -4
- data/lib/ruote-kit/vendor/sinatra-respond_to/lib/sinatra/respond_to.rb +0 -206
- data/lib/ruote-kit/vendor/sinatra-respond_to/sinatra-respond_to.gemspec +0 -56
- data/lib/ruote-kit/vendor/sinatra-respond_to/spec/app/public/static folder/.keep +0 -0
- data/lib/ruote-kit/vendor/sinatra-respond_to/spec/app/public/static.txt +0 -1
- data/lib/ruote-kit/vendor/sinatra-respond_to/spec/app/test_app.rb +0 -53
- data/lib/ruote-kit/vendor/sinatra-respond_to/spec/app/unreachable_static.txt +0 -1
- data/lib/ruote-kit/vendor/sinatra-respond_to/spec/app/views/layout.html.haml +0 -2
- data/lib/ruote-kit/vendor/sinatra-respond_to/spec/app/views/resource.html.haml +0 -1
- data/lib/ruote-kit/vendor/sinatra-respond_to/spec/app/views/resource.js.erb +0 -3
- data/lib/ruote-kit/vendor/sinatra-respond_to/spec/app/views/resource.xml.builder +0 -3
- data/lib/ruote-kit/vendor/sinatra-respond_to/spec/extension_spec.rb +0 -403
- data/lib/ruote-kit/vendor/sinatra-respond_to/spec/spec_helper.rb +0 -18
@@ -1,403 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), 'spec_helper')
|
2
|
-
|
3
|
-
describe Sinatra::RespondTo do
|
4
|
-
def media_type(sym)
|
5
|
-
Sinatra::Base.media_type(sym)
|
6
|
-
end
|
7
|
-
|
8
|
-
describe "options" do
|
9
|
-
it "should initialize with :default_charset set to 'utf-8'" do
|
10
|
-
TestApp.default_charset.should == 'utf-8'
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should initialize with :default_content set to :html" do
|
14
|
-
TestApp.default_content.should == :html
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should initialize with :assume_xhr_is_js set to true" do
|
18
|
-
TestApp.assume_xhr_is_js be_true
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
describe "assume_xhr_is_js" do
|
23
|
-
it "should set the content type to application/javascript for an XMLHttpRequest" do
|
24
|
-
header 'HTTP_X_REQUESTED_WITH', 'XMLHttpRequest'
|
25
|
-
|
26
|
-
get '/resource'
|
27
|
-
|
28
|
-
last_response['Content-Type'].should =~ %r{#{media_type(:js)}}
|
29
|
-
end
|
30
|
-
|
31
|
-
it "should not set the content type to application/javascript for an XMLHttpRequest when assume_xhr_is_js is false" do
|
32
|
-
TestApp.disable :assume_xhr_is_js
|
33
|
-
header 'HTTP_X_REQUESTED_WITH', 'XMLHttpRequest'
|
34
|
-
get '/resource'
|
35
|
-
|
36
|
-
last_response['Content-Type'].should_not =~ %r{#{media_type(:js)}}
|
37
|
-
|
38
|
-
# Put back the option, no side effects here
|
39
|
-
TestApp.enable :assume_xhr_is_js
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
describe "extension routing" do
|
44
|
-
it "breaks routes expecting an extension" do
|
45
|
-
# In test_app.rb the route is defined as get '/style.css' instead of get '/style'
|
46
|
-
get "/style.css"
|
47
|
-
|
48
|
-
last_response.should_not be_ok
|
49
|
-
end
|
50
|
-
|
51
|
-
it "should pick the default content option for routes with out an extension, and render haml templates" do
|
52
|
-
get "/resource"
|
53
|
-
|
54
|
-
last_response.body.should =~ %r{\s*<html>\s*<body>Hello from HTML</body>\s*</html>\s*}
|
55
|
-
end
|
56
|
-
|
57
|
-
it "should render for a template using builder" do
|
58
|
-
get "/resource.xml"
|
59
|
-
|
60
|
-
last_response.body.should =~ %r{\s*<root>Some XML</root>\s*}
|
61
|
-
end
|
62
|
-
|
63
|
-
it "should render for a template using erb" do
|
64
|
-
get "/resource.js"
|
65
|
-
|
66
|
-
last_response.body.should =~ %r{'Hiya from javascript'}
|
67
|
-
end
|
68
|
-
|
69
|
-
it "should return string literals in block" do
|
70
|
-
get "/resource.json"
|
71
|
-
|
72
|
-
last_response.body.should =~ %r{We got some json}
|
73
|
-
end
|
74
|
-
|
75
|
-
# This will fail if the above is failing
|
76
|
-
it "should set the appropriate content-type for route with an extension" do
|
77
|
-
get "/resource.xml"
|
78
|
-
|
79
|
-
last_response['Content-Type'].should =~ %r{#{media_type(:xml)}}
|
80
|
-
end
|
81
|
-
|
82
|
-
it "should set the character set to the default character set" do
|
83
|
-
get "/default_charset"
|
84
|
-
|
85
|
-
last_response['Content-Type'].should =~ %r{charset=#{TestApp.default_charset}}
|
86
|
-
end
|
87
|
-
|
88
|
-
it "should honor a change in character set in block" do
|
89
|
-
get "/iso-8859-1"
|
90
|
-
|
91
|
-
last_response['Content-Type'].should =~ %r{charset=iso-8859-1}
|
92
|
-
end
|
93
|
-
|
94
|
-
it "should not set the character set when requesting a non text resource" do
|
95
|
-
get "/resource.png"
|
96
|
-
|
97
|
-
last_response['Content-Type'].should_not =~ /charset/
|
98
|
-
end
|
99
|
-
|
100
|
-
it "should return not found when path does not exist" do
|
101
|
-
get "/nonexistant-path.txt"
|
102
|
-
|
103
|
-
last_response.status.should == 404
|
104
|
-
end
|
105
|
-
|
106
|
-
describe "for static files" do
|
107
|
-
before(:all) do
|
108
|
-
TestApp.enable :static
|
109
|
-
end
|
110
|
-
|
111
|
-
after(:all) do
|
112
|
-
TestApp.disable :static
|
113
|
-
end
|
114
|
-
|
115
|
-
it "should allow serving static files from public directory" do
|
116
|
-
get '/static.txt'
|
117
|
-
|
118
|
-
last_response.body.should == "A static file"
|
119
|
-
end
|
120
|
-
|
121
|
-
it "should only serve files when static routing is enabled" do
|
122
|
-
TestApp.disable :static
|
123
|
-
get '/static.txt'
|
124
|
-
|
125
|
-
last_response.should_not be_ok
|
126
|
-
last_response.body.should_not == "A static file"
|
127
|
-
|
128
|
-
TestApp.enable :static
|
129
|
-
end
|
130
|
-
|
131
|
-
it "should not allow serving static files from outside the public directory" do
|
132
|
-
get '/../unreachable_static.txt'
|
133
|
-
|
134
|
-
last_response.should_not be_ok
|
135
|
-
last_response.body.should_not == "Unreachable static file"
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
describe "routes not using respond_to" do
|
141
|
-
it "should set the default content type when no extension" do
|
142
|
-
get "/normal-no-respond_to"
|
143
|
-
|
144
|
-
last_response['Content-Type'].should =~ %r{#{media_type(TestApp.default_content)}}
|
145
|
-
end
|
146
|
-
|
147
|
-
it "should set the default character when no extension" do
|
148
|
-
get "/normal-no-respond_to"
|
149
|
-
|
150
|
-
last_response['Content-Type'].should =~ %r{charset=#{TestApp.default_charset}}
|
151
|
-
end
|
152
|
-
|
153
|
-
it "should set the appropriate content type when given an extension" do
|
154
|
-
get "/normal-no-respond_to.css"
|
155
|
-
|
156
|
-
last_response['Content-Type'].should =~ %r{#{media_type(:css)}}
|
157
|
-
end
|
158
|
-
|
159
|
-
it "should set the default charset when given an extension" do
|
160
|
-
get "/normal-no-respond_to.css"
|
161
|
-
|
162
|
-
last_response['Content-Type'].should =~ %r{charset=#{TestApp.default_charset}}
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
|
-
describe "error pages in production" do
|
167
|
-
class ProductionErrorApp < Sinatra::Base
|
168
|
-
set :environment, :production
|
169
|
-
register Sinatra::RespondTo
|
170
|
-
get '/missing-template' do
|
171
|
-
respond_to do |wants|
|
172
|
-
wants.html { haml :missing }
|
173
|
-
end
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
before(:each) do
|
178
|
-
@app = Rack::Builder.new { run ProductionErrorApp }
|
179
|
-
end
|
180
|
-
|
181
|
-
describe Sinatra::RespondTo::MissingTemplate do
|
182
|
-
it "should return 404 status when looking for a missing template in production" do
|
183
|
-
get '/missing-template'
|
184
|
-
|
185
|
-
last_response.status.should == 404
|
186
|
-
last_response.body.should_not =~ /Sinatra can't find/
|
187
|
-
end
|
188
|
-
end
|
189
|
-
|
190
|
-
describe Sinatra::RespondTo::UnhandledFormat do
|
191
|
-
it "should return with a 404 when an extension is not supported in production" do
|
192
|
-
get '/missing-template.txt'
|
193
|
-
|
194
|
-
last_response.status.should == 404
|
195
|
-
last_response.body.should_not =~ /respond_to/
|
196
|
-
end
|
197
|
-
end
|
198
|
-
end
|
199
|
-
|
200
|
-
describe "error pages in development:" do
|
201
|
-
|
202
|
-
it "should allow access to the /__sinatra__/*.png images" do
|
203
|
-
get '/__sinatra__/404.png'
|
204
|
-
|
205
|
-
last_response.should be_ok
|
206
|
-
end
|
207
|
-
|
208
|
-
describe Sinatra::RespondTo::MissingTemplate do
|
209
|
-
it "should return 500 status when looking for a missing template" do
|
210
|
-
get '/missing-template'
|
211
|
-
|
212
|
-
last_response.status.should == 500
|
213
|
-
end
|
214
|
-
|
215
|
-
it "should provide a helpful error message for a missing template when in development" do
|
216
|
-
get '/missing-template'
|
217
|
-
|
218
|
-
last_response.body.should =~ /missing\.html\.haml/
|
219
|
-
end
|
220
|
-
|
221
|
-
it "should show the /__sinatra__/500.png" do
|
222
|
-
get '/missing-template'
|
223
|
-
|
224
|
-
last_response.body.should =~ %r{src='/__sinatra__/500.png'}
|
225
|
-
end
|
226
|
-
|
227
|
-
it "should provide a contextual code example for the template engine" do
|
228
|
-
# Haml
|
229
|
-
get '/missing-template'
|
230
|
-
|
231
|
-
last_response.body.should =~ %r{app.html.haml}
|
232
|
-
last_response.body.should =~ %r{missing-template.html.haml}
|
233
|
-
last_response.body.should =~ %r{get '/missing-template' do respond_to do |wants| wants.html \{ haml :missing-template, layout => :app \} end end}
|
234
|
-
|
235
|
-
# ERB
|
236
|
-
get '/missing-template.js'
|
237
|
-
|
238
|
-
last_response.body.should =~ %r{app.html.erb}
|
239
|
-
last_response.body.should =~ %r{missing-template.html.erb}
|
240
|
-
last_response.body.should =~ %r{get '/missing-template' do respond_to do |wants| wants.html \{ erb :missing-template, layout => :app \} end end}
|
241
|
-
|
242
|
-
# Builder
|
243
|
-
get '/missing-template.xml'
|
244
|
-
|
245
|
-
last_response.body.should =~ %r{app.xml.builder}
|
246
|
-
last_response.body.should =~ %r{missing-template.xml.builder}
|
247
|
-
last_response.body.should =~ %r{get '/missing-template' do respond_to do |wants| wants.xml \{ builder :missing-template, layout => :app \} end end}
|
248
|
-
end
|
249
|
-
end
|
250
|
-
|
251
|
-
describe Sinatra::RespondTo::UnhandledFormat do
|
252
|
-
it "should return with a 404 when an extension is not supported" do
|
253
|
-
get '/missing-template.txt'
|
254
|
-
|
255
|
-
last_response.status.should == 404
|
256
|
-
end
|
257
|
-
|
258
|
-
it "should provide a helpful error message for an unhandled format" do
|
259
|
-
get '/missing-template.txt'
|
260
|
-
|
261
|
-
last_response.body.should =~ %r{get '/missing-template' do respond_to do |wants| wants.txt \{ "Hello World" \} end end}
|
262
|
-
end
|
263
|
-
|
264
|
-
it "should show the /__sinatra__/404.png" do
|
265
|
-
get '/missing-template.txt'
|
266
|
-
|
267
|
-
last_response.body.should =~ %r{src='/__sinatra__/404.png'}
|
268
|
-
end
|
269
|
-
end
|
270
|
-
end
|
271
|
-
|
272
|
-
describe "helpers:" do
|
273
|
-
include Sinatra::RespondTo::Helpers
|
274
|
-
|
275
|
-
before(:each) do
|
276
|
-
stub!(:response).and_return({'Content-Type' => 'text/html'})
|
277
|
-
end
|
278
|
-
|
279
|
-
describe "charset" do
|
280
|
-
it "should set the working charset when called with a non blank string" do
|
281
|
-
response['Content-Type'].should_not =~ /charset/
|
282
|
-
|
283
|
-
charset 'utf-8'
|
284
|
-
|
285
|
-
response['Content-Type'].split(';').should include("charset=utf-8")
|
286
|
-
end
|
287
|
-
|
288
|
-
it "should remove the charset when called with a blank string" do
|
289
|
-
charset 'utf-8'
|
290
|
-
charset ''
|
291
|
-
|
292
|
-
response['Content-Type'].should_not =~ /charset/
|
293
|
-
end
|
294
|
-
|
295
|
-
it "should return the current charset when called with nothing" do
|
296
|
-
charset 'utf-8'
|
297
|
-
|
298
|
-
charset.should == 'utf-8'
|
299
|
-
end
|
300
|
-
|
301
|
-
it "should fail when the response does not have a Content-Type" do
|
302
|
-
response.delete('Content-Type')
|
303
|
-
|
304
|
-
lambda { charset }.should raise_error
|
305
|
-
end
|
306
|
-
|
307
|
-
it "should not modify the Content-Type when given no argument" do
|
308
|
-
response['Content-Type'] = "text/html;charset=iso-8859-1"
|
309
|
-
|
310
|
-
charset
|
311
|
-
|
312
|
-
response['Content-Type'].should == "text/html;charset=iso-8859-1"
|
313
|
-
end
|
314
|
-
end
|
315
|
-
|
316
|
-
describe "format" do
|
317
|
-
before(:each) do
|
318
|
-
stub!(:request).and_return(Sinatra::Request.new({}))
|
319
|
-
end
|
320
|
-
|
321
|
-
it "should set the correct mime type when given an extension" do
|
322
|
-
format :xml
|
323
|
-
|
324
|
-
response['Content-Type'].split(';').should include(media_type(:xml))
|
325
|
-
end
|
326
|
-
|
327
|
-
it "should fail when set to an unknown extension type" do
|
328
|
-
lambda { format :bogus }.should raise_error
|
329
|
-
end
|
330
|
-
|
331
|
-
it "should return the current mime type extension" do
|
332
|
-
format :js
|
333
|
-
|
334
|
-
format.should == :js
|
335
|
-
end
|
336
|
-
|
337
|
-
it "should not modify the Content-Type when given no argument" do
|
338
|
-
response['Content-Type'] = "application/xml;charset=utf-8"
|
339
|
-
|
340
|
-
format
|
341
|
-
|
342
|
-
response['Content-Type'].should == "application/xml;charset=utf-8"
|
343
|
-
end
|
344
|
-
end
|
345
|
-
|
346
|
-
describe "static_file?" do
|
347
|
-
before(:all) do
|
348
|
-
TestApp.enable :static
|
349
|
-
@static_folder = "/static folder/"
|
350
|
-
@reachable_static_file = "/static.txt"
|
351
|
-
@unreachable_static_file = "/../unreachable_static.txt"
|
352
|
-
end
|
353
|
-
|
354
|
-
after(:all) do
|
355
|
-
TestApp.disable :static
|
356
|
-
end
|
357
|
-
|
358
|
-
def options
|
359
|
-
TestApp
|
360
|
-
end
|
361
|
-
|
362
|
-
def unescape(path)
|
363
|
-
Rack::Utils.unescape(path)
|
364
|
-
end
|
365
|
-
|
366
|
-
it "should return true if the request path points to a file in the public directory" do
|
367
|
-
static_file?(@reachable_static_file).should be_true
|
368
|
-
end
|
369
|
-
|
370
|
-
it "should return false when pointing to files outside of the public directory" do
|
371
|
-
static_file?(@unreachable_static_file).should be_false
|
372
|
-
end
|
373
|
-
|
374
|
-
it "should return false when the path is for a folder" do
|
375
|
-
static_file?(@static_folder).should be_false
|
376
|
-
end
|
377
|
-
end
|
378
|
-
|
379
|
-
describe "respond_to" do
|
380
|
-
before(:each) do
|
381
|
-
stub!(:request).and_return(Sinatra::Request.new({}))
|
382
|
-
end
|
383
|
-
|
384
|
-
it "should fail for an unknown extension" do
|
385
|
-
lambda do
|
386
|
-
respond_to do |wants|
|
387
|
-
wants.bogus
|
388
|
-
end
|
389
|
-
end.should raise_error
|
390
|
-
end
|
391
|
-
|
392
|
-
it "should call the block corresponding to the current format" do
|
393
|
-
format :html
|
394
|
-
|
395
|
-
respond_to do |wants|
|
396
|
-
wants.js { "Some JS" }
|
397
|
-
wants.html { "Some HTML" }
|
398
|
-
wants.xml { "Some XML" }
|
399
|
-
end.should == "Some HTML"
|
400
|
-
end
|
401
|
-
end
|
402
|
-
end
|
403
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
#$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require 'spec'
|
5
|
-
require 'rack/test'
|
6
|
-
|
7
|
-
require File.join(File.dirname(__FILE__), '..', 'lib', 'sinatra', 'respond_to')
|
8
|
-
require File.join(File.dirname(__FILE__), 'app', 'test_app')
|
9
|
-
|
10
|
-
Spec::Runner.configure do |config|
|
11
|
-
def app
|
12
|
-
@app ||= Rack::Builder.new do
|
13
|
-
run TestApp
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
config.include Rack::Test::Methods
|
18
|
-
end
|