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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/lib/rack/app/test.rb +31 -5
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 92598b6ab5871f755687a9719455f02f616c2566
4
- data.tar.gz: cd34aafaf566ef166af275daeb02a4d133336998
3
+ metadata.gz: 40170467c938ef8789f4e59c42a605d37bcf2644
4
+ data.tar.gz: 9a836d49866b3593780db3c9301e2fe7179746e3
5
5
  SHA512:
6
- metadata.gz: 2fb15c98af1024b361a429bfbc583e5799a538c9302c65d175db51d2d89d2870e7bf6a3c0f74806b9d8a266a4577dcb39809560278c0dd68f6ba12cd593d92c5
7
- data.tar.gz: c614b65cce23478c9c2e1bc5723ad143b1859d0658d318735d89f694c029693bd6c22315f9e30ce72ddd3319e5b4a572e3b580dae3879078b4cf9f95b7085398
6
+ metadata.gz: 04b40eedb586d5fb194e82ef51be394d833f74efd149260244c38c34e1291e1a4c6baee03a1561183f90f8ca39dc39c785e47ec3a374199370b37c2423201c57
7
+ data.tar.gz: 34d29a887318350acdcb9879e8fcdddab24c3a1c5800095ea01baa69dc08465b7dee1a0b749d9e68eadf5f016561fb11554e5e414733a059b285a3e7397234ee
data/VERSION CHANGED
@@ -1 +1 @@
1
- 7.4.0
1
+ 7.5.0
@@ -1,7 +1,6 @@
1
- require "uri"
2
- require "rack/mock"
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
- return @last_response = mock_request.request(request_method.to_s.upcase, url, request_env)
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
- self.__send_rack_app_request__(request_method_type, *args)
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-app
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.4.0
4
+ version: 7.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Luzsi