rack-app 7.4.0 → 7.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/rack/app/test.rb +31 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40170467c938ef8789f4e59c42a605d37bcf2644
|
4
|
+
data.tar.gz: 9a836d49866b3593780db3c9301e2fe7179746e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04b40eedb586d5fb194e82ef51be394d833f74efd149260244c38c34e1291e1a4c6baee03a1561183f90f8ca39dc39c785e47ec3a374199370b37c2423201c57
|
7
|
+
data.tar.gz: 34d29a887318350acdcb9879e8fcdddab24c3a1c5800095ea01baa69dc08465b7dee1a0b749d9e68eadf5f016561fb11554e5e414733a059b285a3e7397234ee
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
7.
|
1
|
+
7.5.0
|
data/lib/rack/app/test.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'uri'
|
2
|
+
require 'rack/mock'
|
3
3
|
module Rack::App::Test
|
4
|
-
|
5
4
|
require 'rack/app/test/utils'
|
6
5
|
require 'rack/app/test/singleton_methods'
|
7
6
|
|
@@ -16,12 +15,12 @@ module Rack::App::Test
|
|
16
15
|
url = args.detect { |e| e.is_a?(String) } || properties.delete(:url)
|
17
16
|
mock_request = Rack::MockRequest.new(rack_app)
|
18
17
|
request_env = Rack::App::Test::Utils.env_by(url, properties)
|
19
|
-
|
18
|
+
@last_response = mock_request.request(request_method.to_s.upcase, url, request_env)
|
20
19
|
end
|
21
20
|
|
22
21
|
Rack::App::Constants::HTTP::METHODS.each do |request_method_type|
|
23
22
|
define_method(request_method_type.to_s.downcase) do |*args|
|
24
|
-
|
23
|
+
__send_rack_app_request__(request_method_type, *args)
|
25
24
|
end
|
26
25
|
end
|
27
26
|
|
@@ -38,4 +37,31 @@ module Rack::App::Test
|
|
38
37
|
block.is_a?(Proc) ? @rack_app.instance_exec(&block) : @rack_app
|
39
38
|
end
|
40
39
|
|
40
|
+
def mount(app_class, options)
|
41
|
+
path_prefix = options.fetch(:to)
|
42
|
+
|
43
|
+
selector = lambda do |e|
|
44
|
+
if e.config.type == :endpoint
|
45
|
+
e.config.app_class == app_class
|
46
|
+
else
|
47
|
+
e.config.callable == app_class
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
endpoints = rack_app.router.endpoints.select(&selector)
|
52
|
+
|
53
|
+
request_paths_that_has_prefix = lambda do |e|
|
54
|
+
e.request_path.start_with?(path_prefix)
|
55
|
+
end
|
56
|
+
|
57
|
+
matching_endpoints = endpoints.select(&request_paths_that_has_prefix)
|
58
|
+
|
59
|
+
if matching_endpoints.empty?
|
60
|
+
raise("Can't find any path that fullfill the requirement")
|
61
|
+
end
|
62
|
+
|
63
|
+
if matching_endpoints.length != app_class.router.endpoints.length
|
64
|
+
raise("endpoint count not matching")
|
65
|
+
end
|
66
|
+
end
|
41
67
|
end
|