actionpack 5.0.7.2 → 5.1.0.beta1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of actionpack might be problematic. Click here for more details.

Files changed (128) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +189 -1002
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +1 -1
  5. data/lib/abstract_controller.rb +3 -3
  6. data/lib/abstract_controller/base.rb +10 -12
  7. data/lib/abstract_controller/caching.rb +6 -3
  8. data/lib/abstract_controller/caching/fragments.rb +1 -1
  9. data/lib/abstract_controller/callbacks.rb +2 -43
  10. data/lib/abstract_controller/collector.rb +2 -2
  11. data/lib/abstract_controller/helpers.rb +19 -19
  12. data/lib/abstract_controller/rendering.rb +9 -11
  13. data/lib/abstract_controller/translation.rb +3 -3
  14. data/lib/action_controller.rb +15 -13
  15. data/lib/action_controller/api.rb +3 -3
  16. data/lib/action_controller/base.rb +7 -12
  17. data/lib/action_controller/caching.rb +1 -1
  18. data/lib/action_controller/log_subscriber.rb +2 -2
  19. data/lib/action_controller/metal.rb +34 -43
  20. data/lib/action_controller/metal/conditional_get.rb +10 -9
  21. data/lib/action_controller/metal/data_streaming.rb +8 -9
  22. data/lib/action_controller/metal/etag_with_flash.rb +16 -0
  23. data/lib/action_controller/metal/etag_with_template_digest.rb +15 -15
  24. data/lib/action_controller/metal/exceptions.rb +4 -14
  25. data/lib/action_controller/metal/flash.rb +1 -1
  26. data/lib/action_controller/metal/force_ssl.rb +6 -6
  27. data/lib/action_controller/metal/head.rb +13 -19
  28. data/lib/action_controller/metal/helpers.rb +6 -6
  29. data/lib/action_controller/metal/http_authentication.rb +22 -23
  30. data/lib/action_controller/metal/implicit_render.rb +2 -5
  31. data/lib/action_controller/metal/instrumentation.rb +14 -14
  32. data/lib/action_controller/metal/live.rb +15 -16
  33. data/lib/action_controller/metal/mime_responds.rb +3 -3
  34. data/lib/action_controller/metal/parameter_encoding.rb +49 -0
  35. data/lib/action_controller/metal/params_wrapper.rb +32 -32
  36. data/lib/action_controller/metal/redirecting.rb +8 -24
  37. data/lib/action_controller/metal/renderers.rb +2 -3
  38. data/lib/action_controller/metal/rendering.rb +50 -60
  39. data/lib/action_controller/metal/request_forgery_protection.rb +51 -49
  40. data/lib/action_controller/metal/rescue.rb +1 -1
  41. data/lib/action_controller/metal/streaming.rb +4 -4
  42. data/lib/action_controller/metal/strong_parameters.rb +117 -250
  43. data/lib/action_controller/metal/testing.rb +1 -1
  44. data/lib/action_controller/metal/url_for.rb +4 -4
  45. data/lib/action_controller/railtie.rb +9 -13
  46. data/lib/action_controller/renderer.rb +17 -16
  47. data/lib/action_controller/test_case.rb +75 -148
  48. data/lib/action_dispatch.rb +20 -19
  49. data/lib/action_dispatch/http/cache.rb +9 -10
  50. data/lib/action_dispatch/http/filter_parameters.rb +8 -8
  51. data/lib/action_dispatch/http/filter_redirect.rb +2 -4
  52. data/lib/action_dispatch/http/headers.rb +10 -10
  53. data/lib/action_dispatch/http/mime_negotiation.rb +17 -22
  54. data/lib/action_dispatch/http/mime_type.rb +27 -52
  55. data/lib/action_dispatch/http/parameter_filter.rb +8 -6
  56. data/lib/action_dispatch/http/parameters.rb +40 -17
  57. data/lib/action_dispatch/http/request.rb +38 -34
  58. data/lib/action_dispatch/http/response.rb +16 -16
  59. data/lib/action_dispatch/http/upload.rb +6 -10
  60. data/lib/action_dispatch/http/url.rb +48 -74
  61. data/lib/action_dispatch/journey.rb +5 -5
  62. data/lib/action_dispatch/journey/formatter.rb +8 -4
  63. data/lib/action_dispatch/journey/gtg/builder.rb +5 -5
  64. data/lib/action_dispatch/journey/gtg/simulator.rb +1 -1
  65. data/lib/action_dispatch/journey/gtg/transition_table.rb +15 -15
  66. data/lib/action_dispatch/journey/nfa/builder.rb +3 -3
  67. data/lib/action_dispatch/journey/nfa/dot.rb +2 -2
  68. data/lib/action_dispatch/journey/nfa/simulator.rb +1 -1
  69. data/lib/action_dispatch/journey/nfa/transition_table.rb +2 -2
  70. data/lib/action_dispatch/journey/nodes/node.rb +5 -5
  71. data/lib/action_dispatch/journey/parser.rb +23 -24
  72. data/lib/action_dispatch/journey/parser.y +3 -2
  73. data/lib/action_dispatch/journey/parser_extras.rb +2 -2
  74. data/lib/action_dispatch/journey/path/pattern.rb +10 -3
  75. data/lib/action_dispatch/journey/route.rb +19 -12
  76. data/lib/action_dispatch/journey/router.rb +19 -12
  77. data/lib/action_dispatch/journey/router/utils.rb +9 -9
  78. data/lib/action_dispatch/journey/scanner.rb +17 -15
  79. data/lib/action_dispatch/journey/visitors.rb +23 -23
  80. data/lib/action_dispatch/middleware/callbacks.rb +0 -12
  81. data/lib/action_dispatch/middleware/cookies.rb +39 -39
  82. data/lib/action_dispatch/middleware/debug_exceptions.rb +126 -112
  83. data/lib/action_dispatch/middleware/debug_locks.rb +8 -8
  84. data/lib/action_dispatch/middleware/exception_wrapper.rb +55 -55
  85. data/lib/action_dispatch/middleware/executor.rb +1 -1
  86. data/lib/action_dispatch/middleware/flash.rb +17 -16
  87. data/lib/action_dispatch/middleware/public_exceptions.rb +20 -20
  88. data/lib/action_dispatch/middleware/reloader.rb +3 -47
  89. data/lib/action_dispatch/middleware/remote_ip.rb +6 -8
  90. data/lib/action_dispatch/middleware/request_id.rb +6 -5
  91. data/lib/action_dispatch/middleware/session/abstract_store.rb +14 -26
  92. data/lib/action_dispatch/middleware/session/cache_store.rb +3 -3
  93. data/lib/action_dispatch/middleware/session/cookie_store.rb +35 -35
  94. data/lib/action_dispatch/middleware/session/mem_cache_store.rb +2 -2
  95. data/lib/action_dispatch/middleware/show_exceptions.rb +19 -19
  96. data/lib/action_dispatch/middleware/ssl.rb +9 -27
  97. data/lib/action_dispatch/middleware/stack.rb +7 -26
  98. data/lib/action_dispatch/middleware/static.rb +13 -24
  99. data/lib/action_dispatch/railtie.rb +9 -11
  100. data/lib/action_dispatch/request/session.rb +22 -22
  101. data/lib/action_dispatch/request/utils.rb +11 -2
  102. data/lib/action_dispatch/routing.rb +8 -6
  103. data/lib/action_dispatch/routing/inspector.rb +37 -37
  104. data/lib/action_dispatch/routing/mapper.rb +296 -203
  105. data/lib/action_dispatch/routing/polymorphic_routes.rb +160 -134
  106. data/lib/action_dispatch/routing/redirection.rb +27 -22
  107. data/lib/action_dispatch/routing/route_set.rb +206 -92
  108. data/lib/action_dispatch/routing/routes_proxy.rb +2 -2
  109. data/lib/action_dispatch/routing/url_for.rb +14 -12
  110. data/lib/action_dispatch/system_test_case.rb +119 -0
  111. data/lib/action_dispatch/system_testing/browser.rb +28 -0
  112. data/lib/action_dispatch/system_testing/driver.rb +18 -0
  113. data/lib/action_dispatch/system_testing/server.rb +32 -0
  114. data/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb +61 -0
  115. data/lib/action_dispatch/system_testing/test_helpers/setup_and_teardown.rb +20 -0
  116. data/lib/action_dispatch/testing/assertion_response.rb +6 -6
  117. data/lib/action_dispatch/testing/assertions.rb +4 -4
  118. data/lib/action_dispatch/testing/assertions/response.rb +8 -3
  119. data/lib/action_dispatch/testing/assertions/routing.rb +11 -11
  120. data/lib/action_dispatch/testing/integration.rb +47 -138
  121. data/lib/action_dispatch/testing/test_process.rb +2 -2
  122. data/lib/action_dispatch/testing/test_request.rb +16 -16
  123. data/lib/action_dispatch/testing/test_response.rb +1 -1
  124. data/lib/action_pack.rb +2 -2
  125. data/lib/action_pack/gem_version.rb +3 -3
  126. data/lib/action_pack/version.rb +1 -1
  127. metadata +20 -12
  128. data/lib/action_dispatch/middleware/params_parser.rb +0 -46
@@ -1,4 +1,4 @@
1
- require 'active_support/core_ext/array/extract_options'
1
+ require "active_support/core_ext/array/extract_options"
2
2
 
3
3
  module ActionDispatch
4
4
  module Routing
@@ -19,7 +19,7 @@ module ActionDispatch
19
19
  end
20
20
  end
21
21
 
22
- def respond_to?(method, include_private = false)
22
+ def respond_to_missing?(method, include_private = false)
23
23
  super || @helpers.respond_to?(method)
24
24
  end
25
25
 
@@ -194,20 +194,22 @@ module ActionDispatch
194
194
 
195
195
  protected
196
196
 
197
- def optimize_routes_generation?
198
- _routes.optimize_routes_generation? && default_url_options.empty?
199
- end
197
+ def optimize_routes_generation?
198
+ _routes.optimize_routes_generation? && default_url_options.empty?
199
+ end
200
200
 
201
- def _with_routes(routes)
202
- old_routes, @_routes = @_routes, routes
203
- yield
204
- ensure
205
- @_routes = old_routes
206
- end
201
+ private
207
202
 
208
- def _routes_context
209
- self
210
- end
203
+ def _with_routes(routes) # :doc:
204
+ old_routes, @_routes = @_routes, routes
205
+ yield
206
+ ensure
207
+ @_routes = old_routes
208
+ end
209
+
210
+ def _routes_context # :doc:
211
+ self
212
+ end
211
213
  end
212
214
  end
213
215
  end
@@ -0,0 +1,119 @@
1
+ require "capybara/dsl"
2
+ require "action_controller"
3
+ require "action_dispatch/system_testing/driver"
4
+ require "action_dispatch/system_testing/server"
5
+ require "action_dispatch/system_testing/browser"
6
+ require "action_dispatch/system_testing/test_helpers/screenshot_helper"
7
+ require "action_dispatch/system_testing/test_helpers/setup_and_teardown"
8
+
9
+ module ActionDispatch
10
+ # = System Testing
11
+ #
12
+ # System tests let you test applications in the browser. Because system
13
+ # tests use a real browser experience, you can test all of your JavaScript
14
+ # easily from your test suite.
15
+ #
16
+ # To create a system test in your application, extend your test class
17
+ # from <tt>ApplicationSystemTestCase</tt>. System tests use Capybara as a
18
+ # base and allow you to configure the settings through your
19
+ # <tt>application_system_test_case.rb</tt> file that is generated with a new
20
+ # application or scaffold.
21
+ #
22
+ # Here is an example system test:
23
+ #
24
+ # require 'application_system_test_case'
25
+ #
26
+ # class Users::CreateTest < ApplicationSystemTestCase
27
+ # test "adding a new user" do
28
+ # visit users_path
29
+ # click_on 'New User'
30
+ #
31
+ # fill_in 'Name', with: 'Arya'
32
+ # click_on 'Create User'
33
+ #
34
+ # assert_text 'Arya'
35
+ # end
36
+ # end
37
+ #
38
+ # When generating an application or scaffold, an +application_system_test_case.rb+
39
+ # file will also be generated containing the base class for system testing.
40
+ # This is where you can change the driver, add Capybara settings, and other
41
+ # configuration for your system tests.
42
+ #
43
+ # require "test_helper"
44
+ #
45
+ # class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
46
+ # driven_by :selenium, using: :chrome, screen_size: [1400, 1400]
47
+ # end
48
+ #
49
+ # By default, <tt>ActionDispatch::SystemTestCase</tt> is driven by the
50
+ # Selenium driver, with the Chrome browser, and a browser size of 1400x1400.
51
+ #
52
+ # Changing the driver configuration options are easy. Let's say you want to use
53
+ # the Firefox browser instead of Chrome. In your +application_system_test_case.rb+
54
+ # file add the following:
55
+ #
56
+ # require "test_helper"
57
+ #
58
+ # class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
59
+ # driven_by :selenium, using: :firefox
60
+ # end
61
+ #
62
+ # +driven_by+ has a required argument for the driver name. The keyword
63
+ # arguments are +:using+ for the browser and +:screen_size+ to change the
64
+ # size of the browser screen. These two options are not applicable for
65
+ # headless drivers and will be silently ignored if passed.
66
+ #
67
+ # To use a headless driver, like Poltergeist, update your Gemfile to use
68
+ # Poltergeist instead of Selenium and then declare the driver name in the
69
+ # +application_system_test_case.rb+ file. In this case you would leave out the +:using+
70
+ # option because the driver is headless.
71
+ #
72
+ # require "test_helper"
73
+ # require "capybara/poltergeist"
74
+ #
75
+ # class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
76
+ # driven_by :poltergeist
77
+ # end
78
+ #
79
+ # Because <tt>ActionDispatch::SystemTestCase</tt> is a shim between Capybara
80
+ # and Rails, any driver that is supported by Capybara is supported by system
81
+ # tests as long as you include the required gems and files.
82
+ class SystemTestCase < IntegrationTest
83
+ include Capybara::DSL
84
+ include SystemTesting::TestHelpers::SetupAndTeardown
85
+ include SystemTesting::TestHelpers::ScreenshotHelper
86
+
87
+ def self.start_application # :nodoc:
88
+ Capybara.app = Rack::Builder.new do
89
+ map "/" do
90
+ run Rails.application
91
+ end
92
+ end
93
+ end
94
+
95
+ # System Test configuration options
96
+ #
97
+ # The default settings are Selenium, using Chrome, with a screen size
98
+ # of 1400x1400.
99
+ #
100
+ # Examples:
101
+ #
102
+ # driven_by :poltergeist
103
+ #
104
+ # driven_by :selenium, using: :firefox
105
+ #
106
+ # driven_by :selenium, screen_size: [800, 800]
107
+ def self.driven_by(driver, using: :chrome, screen_size: [1400, 1400])
108
+ SystemTesting::Driver.new(driver).run
109
+ SystemTesting::Server.new.run
110
+ SystemTesting::Browser.new(using, screen_size).run if selenium?(driver)
111
+ end
112
+
113
+ def self.selenium?(driver) # :nodoc:
114
+ driver == :selenium
115
+ end
116
+ end
117
+
118
+ SystemTestCase.start_application
119
+ end
@@ -0,0 +1,28 @@
1
+ module ActionDispatch
2
+ module SystemTesting
3
+ class Browser # :nodoc:
4
+ def initialize(name, screen_size)
5
+ @name = name
6
+ @screen_size = screen_size
7
+ end
8
+
9
+ def run
10
+ register
11
+ setup
12
+ end
13
+
14
+ private
15
+ def register
16
+ Capybara.register_driver @name do |app|
17
+ Capybara::Selenium::Driver.new(app, browser: @name).tap do |driver|
18
+ driver.browser.manage.window.size = Selenium::WebDriver::Dimension.new(*@screen_size)
19
+ end
20
+ end
21
+ end
22
+
23
+ def setup
24
+ Capybara.default_driver = @name.to_sym
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,18 @@
1
+ module ActionDispatch
2
+ module SystemTesting
3
+ class Driver # :nodoc:
4
+ def initialize(name)
5
+ @name = name
6
+ end
7
+
8
+ def run
9
+ register
10
+ end
11
+
12
+ private
13
+ def register
14
+ Capybara.default_driver = @name
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,32 @@
1
+ require "rack/handler/puma"
2
+
3
+ module ActionDispatch
4
+ module SystemTesting
5
+ class Server # :nodoc:
6
+ def run
7
+ register
8
+ setup
9
+ end
10
+
11
+ private
12
+ def register
13
+ Capybara.register_server :rails_puma do |app, port, host|
14
+ Rack::Handler::Puma.run(app, Port: port, Threads: "0:1")
15
+ end
16
+ end
17
+
18
+ def setup
19
+ set_server
20
+ set_port
21
+ end
22
+
23
+ def set_server
24
+ Capybara.server = :rails_puma
25
+ end
26
+
27
+ def set_port
28
+ Capybara.always_include_port = true
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,61 @@
1
+ module ActionDispatch
2
+ module SystemTesting
3
+ module TestHelpers
4
+ # Screenshot helper for system testing
5
+ module ScreenshotHelper
6
+ # Takes a screenshot of the current page in the browser.
7
+ #
8
+ # +take_screenshot+ can be used at any point in your system tests to take
9
+ # a screenshot of the current state. This can be useful for debugging or
10
+ # automating visual testing.
11
+ def take_screenshot
12
+ save_image
13
+ puts "[Screenshot]: #{image_path}"
14
+ puts display_image
15
+ end
16
+
17
+ # Takes a screenshot of the current page in the browser if the test
18
+ # failed.
19
+ #
20
+ # +take_failed_screenshot+ is included in <tt>application_system_test_case.rb</tt>
21
+ # that is generated with the application. To take screenshots when a test
22
+ # fails add +take_failed_screenshot+ to the teardown block before clearing
23
+ # sessions.
24
+ def take_failed_screenshot
25
+ take_screenshot if failed?
26
+ end
27
+
28
+ private
29
+ def image_name
30
+ failed? ? "failures_#{method_name}" : method_name
31
+ end
32
+
33
+ def image_path
34
+ "tmp/screenshots/#{image_name}.png"
35
+ end
36
+
37
+ def save_image
38
+ page.save_screenshot(Rails.root.join(image_path))
39
+ end
40
+
41
+ def display_image
42
+ if ENV["CAPYBARA_INLINE_SCREENSHOT"] == "artifact"
43
+ "\e]1338;url=artifact://#{image_path}\a"
44
+ else
45
+ name = inline_base64(File.basename(image_path))
46
+ image = inline_base64(File.read(image_path))
47
+ "\e]1337;File=name=#{name};height=400px;inline=1:#{image}\a"
48
+ end
49
+ end
50
+
51
+ def inline_base64(path)
52
+ Base64.encode64(path).gsub("\n", "")
53
+ end
54
+
55
+ def failed?
56
+ !passed? && !skipped?
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,20 @@
1
+ module ActionDispatch
2
+ module SystemTesting
3
+ module TestHelpers
4
+ module SetupAndTeardown # :nodoc:
5
+ DEFAULT_HOST = "127.0.0.1"
6
+
7
+ def before_setup
8
+ host! DEFAULT_HOST
9
+ super
10
+ end
11
+
12
+ def after_teardown
13
+ super
14
+ take_failed_screenshot
15
+ Capybara.reset_sessions!
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -34,12 +34,12 @@ module ActionDispatch
34
34
 
35
35
  private
36
36
 
37
- def code_from_name(name)
38
- GENERIC_RESPONSE_CODES[name] || Rack::Utils::SYMBOL_TO_STATUS_CODE[name]
39
- end
37
+ def code_from_name(name)
38
+ GENERIC_RESPONSE_CODES[name] || Rack::Utils::SYMBOL_TO_STATUS_CODE[name]
39
+ end
40
40
 
41
- def name_from_code(code)
42
- GENERIC_RESPONSE_CODES.invert[code] || Rack::Utils::HTTP_STATUS_CODES[code]
43
- end
41
+ def name_from_code(code)
42
+ GENERIC_RESPONSE_CODES.invert[code] || Rack::Utils::HTTP_STATUS_CODES[code]
43
+ end
44
44
  end
45
45
  end
@@ -1,9 +1,9 @@
1
- require 'rails-dom-testing'
1
+ require "rails-dom-testing"
2
2
 
3
3
  module ActionDispatch
4
4
  module Assertions
5
- autoload :ResponseAssertions, 'action_dispatch/testing/assertions/response'
6
- autoload :RoutingAssertions, 'action_dispatch/testing/assertions/routing'
5
+ autoload :ResponseAssertions, "action_dispatch/testing/assertions/response"
6
+ autoload :RoutingAssertions, "action_dispatch/testing/assertions/routing"
7
7
 
8
8
  extend ActiveSupport::Concern
9
9
 
@@ -12,7 +12,7 @@ module ActionDispatch
12
12
  include Rails::Dom::Testing::Assertions
13
13
 
14
14
  def html_document
15
- @html_document ||= if @response.content_type.to_s =~ /xml\z/
15
+ @html_document ||= if @response.content_type.to_s.end_with?("xml")
16
16
  Nokogiri::XML::Document.parse(@response.body)
17
17
  else
18
18
  Nokogiri::HTML::Document.parse(@response.body)
@@ -50,7 +50,7 @@ module ActionDispatch
50
50
  #
51
51
  # # Asserts that the redirection matches the regular expression
52
52
  # assert_redirected_to %r(\Ahttp://example.org)
53
- def assert_redirected_to(options = {}, message=nil)
53
+ def assert_redirected_to(options = {}, message = nil)
54
54
  assert_response(:redirect, message)
55
55
  return true if options === @response.location
56
56
 
@@ -79,11 +79,16 @@ module ActionDispatch
79
79
  def generate_response_message(expected, actual = @response.response_code)
80
80
  "Expected response to be a <#{code_with_name(expected)}>,"\
81
81
  " but was a <#{code_with_name(actual)}>"
82
- .concat location_if_redirected
82
+ .concat(location_if_redirected).concat(response_body_if_short)
83
+ end
84
+
85
+ def response_body_if_short
86
+ return "" if @response.body.size > 500
87
+ "\nResponse body: #{@response.body}"
83
88
  end
84
89
 
85
90
  def location_if_redirected
86
- return '' unless @response.redirection? && @response.location.present?
91
+ return "" unless @response.redirection? && @response.location.present?
87
92
  location = normalize_argument_to_redirection(@response.location)
88
93
  " redirect to <#{location}>"
89
94
  end
@@ -1,7 +1,7 @@
1
- require 'uri'
2
- require 'active_support/core_ext/hash/indifferent_access'
3
- require 'active_support/core_ext/string/access'
4
- require 'action_controller/metal/exceptions'
1
+ require "uri"
2
+ require "active_support/core_ext/hash/indifferent_access"
3
+ require "active_support/core_ext/string/access"
4
+ require "action_controller/metal/exceptions"
5
5
 
6
6
  module ActionDispatch
7
7
  module Assertions
@@ -37,7 +37,7 @@ module ActionDispatch
37
37
  #
38
38
  # # Test a custom route
39
39
  # assert_recognizes({controller: 'items', action: 'show', id: '1'}, 'view/item1')
40
- def assert_recognizes(expected_options, path, extras={}, msg=nil)
40
+ def assert_recognizes(expected_options, path, extras = {}, msg = nil)
41
41
  if path.is_a?(Hash) && path[:method].to_s == "all"
42
42
  [:get, :post, :put, :delete].each do |method|
43
43
  assert_recognizes(expected_options, path.merge(method: method), extras, msg)
@@ -75,14 +75,14 @@ module ActionDispatch
75
75
  #
76
76
  # # Asserts that the generated route gives us our custom route
77
77
  # assert_generates "changesets/12", { controller: 'scm', action: 'show_diff', revision: "12" }
78
- def assert_generates(expected_path, options, defaults={}, extras={}, message=nil)
78
+ def assert_generates(expected_path, options, defaults = {}, extras = {}, message = nil)
79
79
  if expected_path =~ %r{://}
80
80
  fail_on(URI::InvalidURIError, message) do
81
81
  uri = URI.parse(expected_path)
82
82
  expected_path = uri.path.to_s.empty? ? "/" : uri.path
83
83
  end
84
84
  else
85
- expected_path = "/#{expected_path}" unless expected_path.first == '/'
85
+ expected_path = "/#{expected_path}" unless expected_path.first == "/"
86
86
  end
87
87
  # Load routes.rb if it hasn't been loaded.
88
88
 
@@ -119,7 +119,7 @@ module ActionDispatch
119
119
  #
120
120
  # # Tests a route with an HTTP method
121
121
  # assert_routing({ method: 'put', path: '/product/321' }, { controller: "product", action: "update", id: "321" })
122
- def assert_routing(path, options, defaults={}, extras={}, message=nil)
122
+ def assert_routing(path, options, defaults = {}, extras = {}, message = nil)
123
123
  assert_recognizes(options, path, extras, message)
124
124
 
125
125
  controller, default_controller = options[:controller], defaults[:controller]
@@ -127,7 +127,7 @@ module ActionDispatch
127
127
  options[:controller] = "/#{controller}"
128
128
  end
129
129
 
130
- generate_options = options.dup.delete_if{ |k, _| defaults.key?(k) }
130
+ generate_options = options.dup.delete_if { |k, _| defaults.key?(k) }
131
131
  assert_generates(path.is_a?(Hash) ? path[:path] : path, generate_options, defaults, extras, message)
132
132
  end
133
133
 
@@ -187,7 +187,7 @@ module ActionDispatch
187
187
  end
188
188
 
189
189
  # Assume given controller
190
- request = ActionController::TestRequest.create
190
+ request = ActionController::TestRequest.create @controller.class
191
191
 
192
192
  if path =~ %r{://}
193
193
  fail_on(URI::InvalidURIError, msg) do
@@ -205,7 +205,7 @@ module ActionDispatch
205
205
  request.request_method = method if method
206
206
 
207
207
  params = fail_on(ActionController::RoutingError, msg) do
208
- @routes.recognize_path(path, { :method => method, :extras => extras })
208
+ @routes.recognize_path(path, method: method, extras: extras)
209
209
  end
210
210
  request.path_parameters = params.with_indifferent_access
211
211