0
@@ -16,7 +16,7 @@ module ActionController
0
# # assert that the response was a redirection
0
- # assert_response :redirect
0
+ # assert_response :redirect
0
# # assert that the response code was status code 401 (unauthorized)
0
@@ -41,7 +41,7 @@ module ActionController
0
- # Assert that the redirection options passed in match those of the redirect called in the latest action.
0
+ # Assert that the redirection options passed in match those of the redirect called in the latest action.
0
# This match can be partial, such that assert_redirected_to(:controller => "weblog") will also
0
# match the redirection of redirect_to(:controller => "weblog", :action => "show") and so on.
0
@@ -60,12 +60,12 @@ module ActionController
0
assert_response(:redirect, message)
0
return true if options == @response.redirected_to
0
# Support partial arguments for hash redirections
0
if options.is_a?(Hash) && @response.redirected_to.is_a?(Hash)
0
return true if options.all? {|(key, value)| @response.redirected_to[key] == value}
0
redirected_to_after_normalisation = normalize_argument_to_redirection(@response.redirected_to)
0
options_after_normalisation = normalize_argument_to_redirection(options)
0
@@ -75,29 +75,59 @@ module ActionController
0
- # Asserts that the request was rendered with the appropriate template file
.0
+ # Asserts that the request was rendered with the appropriate template file
or partials0
# # assert that the "new" view template was rendered
0
# assert_template "new"
0
- def assert_template(expected = nil, message=nil)
0
+ # # assert that the "_customer" partial was rendered twice
0
+ # assert_template :partial => '_customer', :count => 2
0
+ # # assert that no partials were rendered
0
+ # assert_template :partial => false
0
+ def assert_template(options = {}, message = nil)
0
- rendered = @response.rendered_template.to_s
0
- msg = build_message(message, "expecting <?> but rendering with <?>", expected, rendered)
0
- @response.rendered_template.blank?
0
+ rendered = @response.rendered[:template].to_s
0
+ msg = build_message(message,
0
+ "expecting <?> but rendering with <?>",
0
+ @response.rendered[:template].blank?
0
+ rendered.to_s.match(options)
0
+ if expected_partial = options[:partial]
0
+ partials = @response.rendered[:partials]
0
+ if expected_count = options[:count]
0
+ found = partials.detect { |p, _| p.to_s.match(expected_partial) }
0
+ actual_count = found.nil? ? 0 : found.second
0
+ msg = build_message(message,
0
+ "expecting ? to be rendered ? time(s) but rendered ? time(s)",
0
+ expected_partial, expected_count, actual_count)
0
+ assert(actual_count == expected_count.to_i, msg)
0
+ msg = build_message(message,
0
+ "expecting partial <?> but action rendered <?>",
0
+ options[:partial], partials.keys)
0
+ assert(partials.keys.any? { |p| p.to_s.match(expected_partial) }, msg)
0
- rendered.to_s.match(expected)
0
+ assert @response.rendered[:partials].empty?,
0
+ "Expected no partials to be rendered"
0
# Proxy to to_param if the object will respond to it.
0
def parameterize(value)
0
value.respond_to?(:to_param) ? value.to_param : value