aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/test_case.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_controller/test_case.rb')
-rw-r--r--actionpack/lib/action_controller/test_case.rb20
1 files changed, 7 insertions, 13 deletions
diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb
index e96ff82a5a..05e9362463 100644
--- a/actionpack/lib/action_controller/test_case.rb
+++ b/actionpack/lib/action_controller/test_case.rb
@@ -69,15 +69,12 @@ module ActionController
# assert_template :partial => '_customer', :locals => { :customer => @customer }
#
def assert_template(options = {}, message = nil)
- validate_request!
-
case options
when NilClass, String, Symbol
options = options.to_s if Symbol === options
rendered = @templates
- msg = build_message(message,
- "expecting <?> but rendering with <?>",
- options, rendered.keys.join(', '))
+ msg = message || sprintf("expecting <%s> but rendering with <%s>",
+ options, rendered.keys)
assert_block(msg) do
if options
rendered.any? { |t,num| t.match(options) }
@@ -87,13 +84,12 @@ module ActionController
end
when Hash
if expected_layout = options[:layout]
- msg = build_message(message,
- "expecting layout <?> but action rendered <?>",
+ msg = message || sprintf("expecting layout <%s> but action rendered <%s>",
expected_layout, @layouts.keys)
case expected_layout
when String
- assert(@layouts.keys.include?(expected_layout), msg)
+ assert_includes @layouts.keys, expected_layout, msg
when Regexp
assert(@layouts.keys.any? {|l| l =~ expected_layout }, msg)
when nil
@@ -109,15 +105,13 @@ module ActionController
end
elsif expected_count = options[:count]
actual_count = @partials[expected_partial]
- msg = build_message(message,
- "expecting ? to be rendered ? time(s) but rendered ? time(s)",
+ msg = message || sprintf("expecting %s to be rendered %s time(s) but rendered %s time(s)",
expected_partial, expected_count, actual_count)
assert(actual_count == expected_count.to_i, msg)
else
- msg = build_message(message,
- "expecting partial <?> but action rendered <?>",
+ msg = message || sprintf("expecting partial <%s> but action rendered <%s>",
options[:partial], @partials.keys)
- assert(@partials.include?(expected_partial), msg)
+ assert_includes @partials, expected_partial, msg
end
else
assert @partials.empty?,