aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/assertions
diff options
context:
space:
mode:
authorrick <technoweenie@gmail.com>2008-07-16 14:20:15 -0700
committerrick <technoweenie@gmail.com>2008-07-16 14:20:15 -0700
commit0a6d75dedd79407376aae1f01302164dfd3e44b6 (patch)
treedfef7e73b3b19a65895651c82cb6e0b727394eab /actionpack/lib/action_controller/assertions
parenta14cedc7797aef4ccd9da46ed73e36d730392814 (diff)
parentfc89a951933638b051bb1f9e1339ee6ae7c94cda (diff)
downloadrails-0a6d75dedd79407376aae1f01302164dfd3e44b6.tar.gz
rails-0a6d75dedd79407376aae1f01302164dfd3e44b6.tar.bz2
rails-0a6d75dedd79407376aae1f01302164dfd3e44b6.zip
merge with local tweaks
Diffstat (limited to 'actionpack/lib/action_controller/assertions')
-rw-r--r--actionpack/lib/action_controller/assertions/response_assertions.rb17
1 files changed, 12 insertions, 5 deletions
diff --git a/actionpack/lib/action_controller/assertions/response_assertions.rb b/actionpack/lib/action_controller/assertions/response_assertions.rb
index e8a49b2fa6..765225ae24 100644
--- a/actionpack/lib/action_controller/assertions/response_assertions.rb
+++ b/actionpack/lib/action_controller/assertions/response_assertions.rb
@@ -63,11 +63,18 @@ module ActionController
clean_backtrace do
assert_response(:redirect, message)
return true if options == @response.redirected_to
+
+ # Support partial arguments for hash redirections
+ if options.is_a?(Hash) && @response.redirected_to.is_a?(Hash)
+ return true if options.all? {|(key, value)| @response.redirected_to[key] == value}
+ end
+
redirected_to_after_normalisation = normalize_argument_to_redirection(@response.redirected_to)
options_after_normalisation = normalize_argument_to_redirection(options)
- assert_equal options_after_normalisation, redirected_to_after_normalisation,
- "Expected response to be a redirect to <#{options_after_normalisation}> but was a redirect to <#{redirected_to_after_normalisation}>"
+ if redirected_to_after_normalisation != options_after_normalisation
+ flunk "Expected response to be a redirect to <#{options_after_normalisation}> but was a redirect to <#{redirected_to_after_normalisation}>"
+ end
end
end
@@ -80,13 +87,13 @@ module ActionController
#
def assert_template(expected = nil, message=nil)
clean_backtrace do
- rendered = expected ? @response.rendered_file(!expected.include?('/')) : @response.rendered_file
+ rendered = @response.rendered_template
msg = build_message(message, "expecting <?> but rendering with <?>", expected, rendered)
assert_block(msg) do
if expected.nil?
- !@response.rendered_with_file?
+ @response.rendered_template.nil?
else
- expected == rendered
+ rendered.to_s.match(expected)
end
end
end