strelka 0.15.0 → 0.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/ChangeLog +3293 -3058
- data/History.rdoc +17 -0
- data/Manifest.txt +3 -0
- data/Rakefile +2 -2
- data/contrib/hoetemplate/lib/file_name.rb.erb +3 -2
- data/contrib/hoetemplate/spec/file_name_spec.rb.erb +1 -1
- data/examples/apps/auth-demo +1 -2
- data/examples/apps/auth-demo2 +1 -2
- data/examples/apps/sessions-demo +1 -2
- data/examples/gen-config.rb +1 -2
- data/lib/strelka.rb +92 -17
- data/lib/strelka/app.rb +7 -6
- data/lib/strelka/app/auth.rb +5 -5
- data/lib/strelka/app/errors.rb +1 -1
- data/lib/strelka/app/filters.rb +1 -1
- data/lib/strelka/app/negotiation.rb +1 -1
- data/lib/strelka/app/parameters.rb +1 -1
- data/lib/strelka/app/restresources.rb +14 -21
- data/lib/strelka/app/routing.rb +5 -6
- data/lib/strelka/app/sessions.rb +3 -1
- data/lib/strelka/app/templating.rb +1 -1
- data/lib/strelka/authprovider.rb +1 -1
- data/lib/strelka/authprovider/basic.rb +1 -0
- data/lib/strelka/authprovider/hostaccess.rb +1 -0
- data/lib/strelka/behavior/plugin.rb +2 -2
- data/lib/strelka/cli.rb +2 -1
- data/lib/strelka/command/config.rb +2 -1
- data/lib/strelka/command/discover.rb +2 -1
- data/lib/strelka/command/start.rb +2 -1
- data/lib/strelka/constants.rb +1 -1
- data/lib/strelka/cookie.rb +1 -1
- data/lib/strelka/cookieset.rb +1 -1
- data/lib/strelka/discovery.rb +1 -1
- data/lib/strelka/httprequest.rb +4 -4
- data/lib/strelka/httprequest/acceptparams.rb +1 -1
- data/lib/strelka/httprequest/auth.rb +3 -1
- data/lib/strelka/httprequest/negotiation.rb +1 -1
- data/lib/strelka/httprequest/session.rb +3 -1
- data/lib/strelka/httpresponse.rb +2 -3
- data/lib/strelka/httpresponse/negotiation.rb +1 -1
- data/lib/strelka/httpresponse/session.rb +1 -1
- data/lib/strelka/mixins.rb +26 -5
- data/lib/strelka/multipartparser.rb +3 -3
- data/lib/strelka/paramvalidator.rb +4 -4
- data/lib/strelka/plugins.rb +14 -5
- data/lib/strelka/router.rb +1 -1
- data/lib/strelka/router/default.rb +1 -1
- data/lib/strelka/router/exclusive.rb +1 -1
- data/lib/strelka/session.rb +1 -0
- data/lib/strelka/session/db.rb +1 -0
- data/lib/strelka/session/default.rb +1 -0
- data/lib/strelka/testing.rb +454 -14
- data/lib/strelka/websocketserver.rb +150 -36
- data/lib/strelka/websocketserver/heartbeat.rb +163 -0
- data/lib/strelka/websocketserver/routing.rb +46 -19
- data/spec/constants.rb +1 -1
- data/spec/helpers.rb +15 -6
- data/spec/strelka/app/auth_spec.rb +5 -3
- data/spec/strelka/app/errors_spec.rb +2 -2
- data/spec/strelka/app/filters_spec.rb +2 -2
- data/spec/strelka/app/negotiation_spec.rb +2 -2
- data/spec/strelka/app/parameters_spec.rb +5 -5
- data/spec/strelka/app/restresources_spec.rb +8 -6
- data/spec/strelka/app/routing_spec.rb +3 -3
- data/spec/strelka/app/sessions_spec.rb +4 -2
- data/spec/strelka/app/templating_spec.rb +2 -2
- data/spec/strelka/app_spec.rb +5 -24
- data/spec/strelka/authprovider/basic_spec.rb +3 -2
- data/spec/strelka/authprovider/hostaccess_spec.rb +3 -2
- data/spec/strelka/authprovider_spec.rb +3 -2
- data/spec/strelka/cli_spec.rb +7 -4
- data/spec/strelka/cookie_spec.rb +2 -2
- data/spec/strelka/cookieset_spec.rb +2 -2
- data/spec/strelka/discovery_spec.rb +2 -2
- data/spec/strelka/exceptions_spec.rb +2 -2
- data/spec/strelka/httprequest/acceptparams_spec.rb +2 -2
- data/spec/strelka/httprequest/auth_spec.rb +3 -2
- data/spec/strelka/httprequest/negotiation_spec.rb +2 -2
- data/spec/strelka/httprequest/session_spec.rb +3 -2
- data/spec/strelka/httprequest_spec.rb +7 -2
- data/spec/strelka/httpresponse/negotiation_spec.rb +6 -5
- data/spec/strelka/httpresponse/session_spec.rb +3 -2
- data/spec/strelka/httpresponse_spec.rb +4 -3
- data/spec/strelka/mixins_spec.rb +85 -2
- data/spec/strelka/multipartparser_spec.rb +5 -4
- data/spec/strelka/paramvalidator_spec.rb +15 -10
- data/spec/strelka/plugins_spec.rb +24 -2
- data/spec/strelka/router/default_spec.rb +2 -2
- data/spec/strelka/router/exclusive_spec.rb +2 -2
- data/spec/strelka/router_spec.rb +2 -2
- data/spec/strelka/session/db_spec.rb +3 -2
- data/spec/strelka/session/default_spec.rb +3 -2
- data/spec/strelka/session_spec.rb +3 -2
- data/spec/strelka/testing_spec.rb +772 -0
- data/spec/strelka/websocketserver/heartbeat_spec.rb +19 -0
- data/spec/strelka/websocketserver/routing_spec.rb +31 -29
- data/spec/strelka/websocketserver_spec.rb +210 -75
- data/spec/strelka_spec.rb +172 -2
- metadata +43 -36
- metadata.gz.sig +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- ruby -*-
|
2
2
|
# vim: set nosta noet ts=4 sw=4:
|
3
|
-
#
|
3
|
+
# frozen-string-literal: true
|
4
4
|
|
5
5
|
require_relative '../helpers'
|
6
6
|
|
@@ -15,7 +15,7 @@ require 'strelka/discovery'
|
|
15
15
|
### C O N T E X T S
|
16
16
|
#####################################################################
|
17
17
|
|
18
|
-
describe Strelka::Discovery do
|
18
|
+
RSpec.describe Strelka::Discovery do
|
19
19
|
|
20
20
|
before( :all ) do
|
21
21
|
@real_discovered_apps = described_class.instance_variable_get( :@discovered_apps )
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- ruby -*-
|
2
2
|
# vim: set nosta noet ts=4 sw=4:
|
3
|
-
#
|
3
|
+
# frozen-string-literal: true
|
4
4
|
|
5
5
|
require_relative '../helpers'
|
6
6
|
|
@@ -15,7 +15,7 @@ require 'strelka/exceptions'
|
|
15
15
|
### C O N T E X T S
|
16
16
|
#####################################################################
|
17
17
|
|
18
|
-
describe Strelka, "exception classes" do
|
18
|
+
RSpec.describe Strelka, "exception classes" do
|
19
19
|
|
20
20
|
before( :all ) do
|
21
21
|
@request_factory = Mongrel2::RequestFactory.new( route: '/exceptions' )
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- ruby -*-
|
2
2
|
# vim: set nosta noet ts=4 sw=4:
|
3
|
-
#
|
3
|
+
# frozen-string-literal: true
|
4
4
|
|
5
5
|
require_relative '../../helpers'
|
6
6
|
|
@@ -14,7 +14,7 @@ require 'strelka/httprequest/acceptparams'
|
|
14
14
|
### C O N T E X T S
|
15
15
|
#####################################################################
|
16
16
|
|
17
|
-
describe Strelka::HTTPRequest, "accept params" do
|
17
|
+
RSpec.describe Strelka::HTTPRequest, "accept params" do
|
18
18
|
|
19
19
|
|
20
20
|
describe Strelka::HTTPRequest::MediaType do
|
@@ -1,5 +1,6 @@
|
|
1
|
-
# -*-
|
1
|
+
# -*- ruby -*-
|
2
2
|
# vim: set nosta noet ts=4 sw=4:
|
3
|
+
# frozen-string-literal: true
|
3
4
|
|
4
5
|
require_relative '../../helpers'
|
5
6
|
|
@@ -14,7 +15,7 @@ require 'strelka/httprequest/auth'
|
|
14
15
|
### C O N T E X T S
|
15
16
|
#####################################################################
|
16
17
|
|
17
|
-
describe Strelka::HTTPRequest::Auth do
|
18
|
+
RSpec.describe Strelka::HTTPRequest::Auth do
|
18
19
|
|
19
20
|
before( :all ) do
|
20
21
|
@request_factory = Mongrel2::RequestFactory.new( route: '/service/user' )
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- ruby -*-
|
2
2
|
# vim: set nosta noet ts=4 sw=4:
|
3
|
-
#
|
3
|
+
# frozen-string-literal: true
|
4
4
|
|
5
5
|
require_relative '../../helpers'
|
6
6
|
|
@@ -15,7 +15,7 @@ require 'strelka/httpresponse/negotiation'
|
|
15
15
|
### C O N T E X T S
|
16
16
|
#####################################################################
|
17
17
|
|
18
|
-
describe Strelka::HTTPRequest::Negotiation do
|
18
|
+
RSpec.describe Strelka::HTTPRequest::Negotiation do
|
19
19
|
|
20
20
|
before( :all ) do
|
21
21
|
@request_factory = Mongrel2::RequestFactory.new( route: '/service/user' )
|
@@ -1,5 +1,6 @@
|
|
1
|
-
# -*-
|
1
|
+
# -*- ruby -*-
|
2
2
|
# vim: set nosta noet ts=4 sw=4:
|
3
|
+
# frozen-string-literal: true
|
3
4
|
|
4
5
|
require_relative '../../helpers'
|
5
6
|
|
@@ -15,7 +16,7 @@ require 'strelka/session/default'
|
|
15
16
|
### C O N T E X T S
|
16
17
|
#####################################################################
|
17
18
|
|
18
|
-
describe Strelka::HTTPRequest::Session, "-extended request" do
|
19
|
+
RSpec.describe Strelka::HTTPRequest::Session, "-extended request" do
|
19
20
|
|
20
21
|
before( :all ) do
|
21
22
|
@request_factory = Mongrel2::RequestFactory.new( route: '/service/user' )
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- ruby -*-
|
2
2
|
# vim: set nosta noet ts=4 sw=4:
|
3
|
-
#
|
3
|
+
# frozen-string-literal: true
|
4
4
|
|
5
5
|
require_relative '../helpers'
|
6
6
|
|
@@ -14,7 +14,7 @@ require 'strelka/cookie'
|
|
14
14
|
### C O N T E X T S
|
15
15
|
#####################################################################
|
16
16
|
|
17
|
-
describe Strelka::HTTPRequest do
|
17
|
+
RSpec.describe Strelka::HTTPRequest do
|
18
18
|
|
19
19
|
before( :all ) do
|
20
20
|
@request_factory = Mongrel2::RequestFactory.new( route: '/directory' )
|
@@ -54,6 +54,10 @@ describe Strelka::HTTPRequest do
|
|
54
54
|
expect( @req.base_uri.to_s ).to eq( 'http://localhost:8080/directory' )
|
55
55
|
end
|
56
56
|
|
57
|
+
it "doesn't modify its URI when calculating its base URI" do
|
58
|
+
expect { @req.base_uri }.to_not change { @req.uri }
|
59
|
+
end
|
60
|
+
|
57
61
|
it "knows what the path of the request past its route is" do
|
58
62
|
expect( @req.app_path ).to eq( '/userinfo/ged' )
|
59
63
|
end
|
@@ -77,6 +81,7 @@ describe Strelka::HTTPRequest do
|
|
77
81
|
@req.redirect( uri, true )
|
78
82
|
}.to finish_with( HTTP::MOVED_PERMANENTLY, nil, :location => uri )
|
79
83
|
end
|
84
|
+
|
80
85
|
end
|
81
86
|
|
82
87
|
|
@@ -1,5 +1,6 @@
|
|
1
|
-
|
2
|
-
#
|
1
|
+
# -*- ruby -*-
|
2
|
+
# vim: set nosta noet ts=4 sw=4:
|
3
|
+
# frozen-string-literal: true
|
3
4
|
|
4
5
|
require_relative '../../helpers'
|
5
6
|
|
@@ -14,7 +15,7 @@ require 'strelka/httpresponse/negotiation'
|
|
14
15
|
### C O N T E X T S
|
15
16
|
#####################################################################
|
16
17
|
|
17
|
-
describe Strelka::HTTPResponse::Negotiation do
|
18
|
+
RSpec.describe Strelka::HTTPResponse::Negotiation do
|
18
19
|
|
19
20
|
before( :all ) do
|
20
21
|
@request_factory = Mongrel2::RequestFactory.new( route: '/service/user' )
|
@@ -327,7 +328,7 @@ describe Strelka::HTTPResponse::Negotiation do
|
|
327
328
|
"acceptable charsets includes ISO8859-1" do
|
328
329
|
@req.headers.accept_charset = 'iso-8859-1, utf-8;q=0.8'
|
329
330
|
@res.content_type = 'text/plain'
|
330
|
-
@res.body = "some stuff".force_encoding( Encoding::ASCII_8BIT )
|
331
|
+
@res.body = "some stuff".dup.force_encoding( Encoding::ASCII_8BIT )
|
331
332
|
|
332
333
|
expect( @res ).to have_acceptable_charset()
|
333
334
|
end
|
@@ -336,7 +337,7 @@ describe Strelka::HTTPResponse::Negotiation do
|
|
336
337
|
"text subtype, and the list of acceptable charsets doesn't include ISO8859-1" do
|
337
338
|
@req.headers.accept_charset = 'iso-8859-15, utf-8;q=0.8'
|
338
339
|
@res.content_type = 'text/plain'
|
339
|
-
@res.body = "some stuff".force_encoding( Encoding::ASCII_8BIT )
|
340
|
+
@res.body = "some stuff".dup.force_encoding( Encoding::ASCII_8BIT )
|
340
341
|
|
341
342
|
expect( @res ).to_not have_acceptable_charset()
|
342
343
|
end
|
@@ -1,5 +1,6 @@
|
|
1
|
-
# -*-
|
1
|
+
# -*- ruby -*-
|
2
2
|
# vim: set nosta noet ts=4 sw=4:
|
3
|
+
# frozen-string-literal: true
|
3
4
|
|
4
5
|
require_relative '../../helpers'
|
5
6
|
|
@@ -16,7 +17,7 @@ require 'strelka/session/default'
|
|
16
17
|
### C O N T E X T S
|
17
18
|
#####################################################################
|
18
19
|
|
19
|
-
describe Strelka::HTTPResponse::Session, "-extended response" do
|
20
|
+
RSpec.describe Strelka::HTTPResponse::Session, "-extended response" do
|
20
21
|
|
21
22
|
before( :all ) do
|
22
23
|
@request_factory = Mongrel2::RequestFactory.new( route: '/service/user' )
|
@@ -1,5 +1,6 @@
|
|
1
|
-
|
2
|
-
#
|
1
|
+
# -*- ruby -*-
|
2
|
+
# vim: set nosta noet ts=4 sw=4:
|
3
|
+
# frozen-string-literal: true
|
3
4
|
|
4
5
|
require_relative '../helpers'
|
5
6
|
|
@@ -11,7 +12,7 @@ require 'strelka/httpresponse'
|
|
11
12
|
### C O N T E X T S
|
12
13
|
#####################################################################
|
13
14
|
|
14
|
-
describe Strelka::HTTPResponse do
|
15
|
+
RSpec.describe Strelka::HTTPResponse do
|
15
16
|
|
16
17
|
before( :all ) do
|
17
18
|
@request_factory = Mongrel2::RequestFactory.new( route: '/glossary' )
|
data/spec/strelka/mixins_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- ruby -*-
|
2
2
|
# vim: set nosta noet ts=4 sw=4:
|
3
|
-
#
|
3
|
+
# frozen-string-literal: true
|
4
4
|
|
5
5
|
require_relative '../helpers'
|
6
6
|
|
@@ -13,7 +13,7 @@ require 'strelka/mixins'
|
|
13
13
|
### C O N T E X T S
|
14
14
|
#####################################################################
|
15
15
|
|
16
|
-
describe Strelka, "mixins" do
|
16
|
+
RSpec.describe Strelka, "mixins" do
|
17
17
|
|
18
18
|
|
19
19
|
describe Strelka::AbstractClass do
|
@@ -301,5 +301,88 @@ describe Strelka, "mixins" do
|
|
301
301
|
|
302
302
|
end
|
303
303
|
|
304
|
+
|
305
|
+
describe Strelka::MethodUtilities, 'used to extend a class' do
|
306
|
+
|
307
|
+
let!( :extended_class ) do
|
308
|
+
klass = Class.new
|
309
|
+
klass.extend( Strelka::MethodUtilities )
|
310
|
+
klass
|
311
|
+
end
|
312
|
+
|
313
|
+
it "can declare a class-level attribute reader" do
|
314
|
+
extended_class.singleton_attr_reader :foo
|
315
|
+
expect( extended_class ).to respond_to( :foo )
|
316
|
+
expect( extended_class ).to_not respond_to( :foo= )
|
317
|
+
expect( extended_class ).to_not respond_to( :foo? )
|
318
|
+
end
|
319
|
+
|
320
|
+
it "can declare a class-level attribute writer" do
|
321
|
+
extended_class.singleton_attr_writer :foo
|
322
|
+
expect( extended_class ).to_not respond_to( :foo )
|
323
|
+
expect( extended_class ).to respond_to( :foo= )
|
324
|
+
expect( extended_class ).to_not respond_to( :foo? )
|
325
|
+
end
|
326
|
+
|
327
|
+
it "can declare a class-level attribute reader and writer" do
|
328
|
+
extended_class.singleton_attr_accessor :foo
|
329
|
+
expect( extended_class ).to respond_to( :foo )
|
330
|
+
expect( extended_class ).to respond_to( :foo= )
|
331
|
+
expect( extended_class ).to_not respond_to( :foo? )
|
332
|
+
end
|
333
|
+
|
334
|
+
it "can declare a class-level alias" do
|
335
|
+
def extended_class.foo
|
336
|
+
return "foo"
|
337
|
+
end
|
338
|
+
extended_class.singleton_method_alias( :bar, :foo )
|
339
|
+
|
340
|
+
expect( extended_class.bar ).to eq( 'foo' )
|
341
|
+
end
|
342
|
+
|
343
|
+
it "can declare an instance attribute predicate method" do
|
344
|
+
extended_class.attr_predicate :foo
|
345
|
+
instance = extended_class.new
|
346
|
+
|
347
|
+
expect( instance ).to_not respond_to( :foo )
|
348
|
+
expect( instance ).to_not respond_to( :foo= )
|
349
|
+
expect( instance ).to respond_to( :foo? )
|
350
|
+
|
351
|
+
expect( instance.foo? ).to be_falsey
|
352
|
+
|
353
|
+
instance.instance_variable_set( :@foo, 1 )
|
354
|
+
expect( instance.foo? ).to be_truthy
|
355
|
+
end
|
356
|
+
|
357
|
+
it "can declare an instance attribute predicate and writer" do
|
358
|
+
extended_class.attr_predicate_accessor :foo
|
359
|
+
instance = extended_class.new
|
360
|
+
|
361
|
+
expect( instance ).to_not respond_to( :foo )
|
362
|
+
expect( instance ).to respond_to( :foo= )
|
363
|
+
expect( instance ).to respond_to( :foo? )
|
364
|
+
|
365
|
+
expect( instance.foo? ).to be_falsey
|
366
|
+
|
367
|
+
instance.foo = 1
|
368
|
+
expect( instance.foo? ).to be_truthy
|
369
|
+
end
|
370
|
+
|
371
|
+
it "can declare a class-level attribute predicate and writer" do
|
372
|
+
extended_class.singleton_predicate_accessor :foo
|
373
|
+
expect( extended_class ).to_not respond_to( :foo )
|
374
|
+
expect( extended_class ).to respond_to( :foo= )
|
375
|
+
expect( extended_class ).to respond_to( :foo? )
|
376
|
+
end
|
377
|
+
|
378
|
+
it "can declare a class-level predicate method" do
|
379
|
+
extended_class.singleton_predicate_reader :foo
|
380
|
+
expect( extended_class ).to_not respond_to( :foo )
|
381
|
+
expect( extended_class ).to_not respond_to( :foo= )
|
382
|
+
expect( extended_class ).to respond_to( :foo? )
|
383
|
+
end
|
384
|
+
|
385
|
+
end
|
386
|
+
|
304
387
|
end
|
305
388
|
|
@@ -1,5 +1,6 @@
|
|
1
|
-
|
2
|
-
#
|
1
|
+
# -*- ruby -*-
|
2
|
+
# vim: set nosta noet ts=4 sw=4:
|
3
|
+
# frozen-string-literal: true
|
3
4
|
|
4
5
|
require_relative '../helpers'
|
5
6
|
|
@@ -13,7 +14,7 @@ require 'strelka/multipartparser'
|
|
13
14
|
#####################################################################
|
14
15
|
### C O N T E X T S
|
15
16
|
#####################################################################
|
16
|
-
describe Strelka::MultipartParser do
|
17
|
+
RSpec.describe Strelka::MultipartParser do
|
17
18
|
|
18
19
|
BOUNDARY = 'sillyBoundary'
|
19
20
|
MIMEPARSER_SPECDIR = Pathname.new( __FILE__ ).dirname.parent
|
@@ -138,7 +139,7 @@ describe Strelka::MultipartParser do
|
|
138
139
|
end
|
139
140
|
|
140
141
|
|
141
|
-
JPEG_MAGIC = "\xff\xd8".
|
142
|
+
JPEG_MAGIC = "\xff\xd8".b
|
142
143
|
|
143
144
|
it "parses the files from multiple uploads" do
|
144
145
|
socket = load_form( "2_images.form" )
|
@@ -1,5 +1,6 @@
|
|
1
|
-
|
2
|
-
#
|
1
|
+
# -*- ruby -*-
|
2
|
+
# vim: set nosta noet ts=4 sw=4:
|
3
|
+
# frozen-string-literal: true
|
3
4
|
|
4
5
|
require_relative '../helpers'
|
5
6
|
|
@@ -13,7 +14,12 @@ require 'strelka/paramvalidator'
|
|
13
14
|
#####################################################################
|
14
15
|
### C O N T E X T S
|
15
16
|
#####################################################################
|
16
|
-
describe Strelka::ParamValidator do
|
17
|
+
RSpec.describe Strelka::ParamValidator do
|
18
|
+
|
19
|
+
# Utility function to make tainted frozen strings out of frozen string literals
|
20
|
+
def tainted( string )
|
21
|
+
return ( +string ).taint.freeze
|
22
|
+
end
|
17
23
|
|
18
24
|
|
19
25
|
before(:each) do
|
@@ -133,8 +139,7 @@ describe Strelka::ParamValidator do
|
|
133
139
|
end
|
134
140
|
|
135
141
|
it "untaints valid args if told to do so" do
|
136
|
-
tainted_one = "1"
|
137
|
-
tainted_one.taint
|
142
|
+
tainted_one = tainted( "1" )
|
138
143
|
|
139
144
|
@validator.add( :number, /^\d+$/, :untaint )
|
140
145
|
@validator.validate( 'number' => tainted_one )
|
@@ -343,10 +348,10 @@ describe Strelka::ParamValidator do
|
|
343
348
|
@validator.untaint_all_constraints = true
|
344
349
|
|
345
350
|
args = {
|
346
|
-
'recipe[ingredient][rarity]'
|
347
|
-
'recipe[ingredient][name]'
|
348
|
-
'recipe[ingredient][cost]'
|
349
|
-
'recipe[yield]'
|
351
|
+
tainted('recipe[ingredient][rarity]') => tainted('super-rare'),
|
352
|
+
tainted('recipe[ingredient][name]') => tainted('nutmeg'),
|
353
|
+
tainted('recipe[ingredient][cost]') => tainted('$0.18'),
|
354
|
+
tainted('recipe[yield]') => tainted('2 loaves'),
|
350
355
|
}
|
351
356
|
@validator.validate( args )
|
352
357
|
|
@@ -449,7 +454,7 @@ describe Strelka::ParamValidator do
|
|
449
454
|
|
450
455
|
it "returns the captures with named captures as a Hash" do
|
451
456
|
@validator.add( :order_number, /(?<category>[[:upper:]]{3})-(?<sku>\d{12})/, :untaint )
|
452
|
-
@validator.validate( 'order_number' => " JVV-886451300133 "
|
457
|
+
@validator.validate( 'order_number' => tainted(" JVV-886451300133 ") )
|
453
458
|
|
454
459
|
expect( @validator[:order_number] ).to eq( {:category => 'JVV', :sku => '886451300133'} )
|
455
460
|
expect( @validator[:order_number][:category] ).to_not be_tainted()
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- ruby -*-
|
2
2
|
# vim: set nosta noet ts=4 sw=4:
|
3
|
-
#
|
3
|
+
# frozen-string-literal: true
|
4
4
|
|
5
5
|
require_relative '../helpers'
|
6
6
|
|
@@ -19,7 +19,7 @@ class Strelka::Pluggable
|
|
19
19
|
end
|
20
20
|
|
21
21
|
|
22
|
-
describe "Strelka plugin system" do
|
22
|
+
RSpec.describe "Strelka plugin system" do
|
23
23
|
|
24
24
|
before( :all ) do
|
25
25
|
@original_registry = Strelka::Pluggable.loaded_plugins.dup
|
@@ -181,6 +181,28 @@ describe "Strelka plugin system" do
|
|
181
181
|
expect( app.testing_value ).to eq( :pre_existing_value )
|
182
182
|
end
|
183
183
|
|
184
|
+
|
185
|
+
it "passes a block to the plugin's ::init_block if given" do
|
186
|
+
plugin = Module.new do
|
187
|
+
def self::name; "Strelka::Pluggable::InitBlockTestPlugin"; end
|
188
|
+
def self::configure_block( object, &block )
|
189
|
+
object.block = block
|
190
|
+
end
|
191
|
+
include Strelka::Plugin
|
192
|
+
|
193
|
+
module ClassMethods
|
194
|
+
@block = nil
|
195
|
+
attr_accessor :block
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
app = Class.new( Strelka::Pluggable )
|
200
|
+
block = Proc.new {}
|
201
|
+
app.register_plugin( plugin, &block )
|
202
|
+
|
203
|
+
expect( app.block ).to be( block )
|
204
|
+
end
|
205
|
+
|
184
206
|
end
|
185
207
|
|
186
208
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- ruby -*-
|
2
2
|
# vim: set nosta noet ts=4 sw=4:
|
3
|
-
#
|
3
|
+
# frozen-string-literal: true
|
4
4
|
|
5
5
|
require_relative '../../helpers'
|
6
6
|
|
@@ -14,7 +14,7 @@ require 'strelka/router/default'
|
|
14
14
|
### C O N T E X T S
|
15
15
|
#####################################################################
|
16
16
|
|
17
|
-
describe Strelka::Router::Default do
|
17
|
+
RSpec.describe Strelka::Router::Default do
|
18
18
|
|
19
19
|
before( :all ) do
|
20
20
|
@request_factory = Mongrel2::RequestFactory.new( route: '/user' )
|