Module: SubdomainRoutes::RoutingAssertions
- Includes:
- RewriteSubdomainOptions
- Defined in:
- lib/subdomain_routes/assertions.rb
Instance Method Summary collapse
- #assert_generates_with_host(expected_path, options, host, defaults = {}, extras = {}, message = nil) ⇒ Object
- #assert_recognizes_with_host(expected_options, path, extras = {}, message = nil) ⇒ Object
Methods included from RewriteSubdomainOptions
#rewrite_subdomain_options, #subdomain_procs
Instance Method Details
#assert_generates_with_host(expected_path, options, host, defaults = {}, extras = {}, message = nil) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/subdomain_routes/assertions.rb', line 31 def assert_generates_with_host(expected_path, , host, defaults={}, extras = {}, =nil) if expected_path.is_a? Hash expected_host = expected_path[:host] expected_path = expected_path[:path] else expected_host = nil end (, host) if .delete(:only_path) == false generated_host = .delete(:host) msg = expected_host ? (, "The route for <?> changed the host to <?> but this did not match expected host <?>", , generated_host, expected_host) : (, "The route for <?> changed the host to <?> but the host was not expected to change", , generated_host) assert_block(msg) { expected_host == generated_host } else msg = (, "The route for <?> was expected to change the host to <?> but did not change the host", , expected_host) assert_block(msg) { expected_host == nil } end assert_generates(expected_path, , defaults, extras, ) end |
#assert_recognizes_with_host(expected_options, path, extras = {}, message = nil) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/subdomain_routes/assertions.rb', line 5 def assert_recognizes_with_host(, path, extras={}, =nil) # copied from Rails source, with modification to set the the supplied host on the request if path.is_a? Hash request_method = path[:method] host = path[:host] path = path[:path] else request_method = nil host = nil end clean_backtrace do ActionController::Routing::Routes.reload if ActionController::Routing::Routes.empty? request = recognized_request_for_with_host(path, host, request_method) = .clone extras.each_key { |key| .delete key } unless extras.nil? .stringify_keys! routing_diff = .diff(request.path_parameters) msg = (, "The recognized options <?> did not match <?>, difference: <?>", request.path_parameters, , .diff(request.path_parameters)) assert_block(msg) { request.path_parameters == } end end |