aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionpack/lib/action_controller/test_case.rb3
-rw-r--r--actionpack/test/controller/action_pack_assertions_test.rb29
2 files changed, 27 insertions, 5 deletions
diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb
index 2010d8573c..34499fa784 100644
--- a/actionpack/lib/action_controller/test_case.rb
+++ b/actionpack/lib/action_controller/test_case.rb
@@ -57,7 +57,8 @@ module ActionController
validate_request!
case options
- when NilClass, String
+ when NilClass, String, Symbol
+ options = options.to_s if Symbol === options
rendered = @templates
msg = build_message(message,
"expecting <?> but rendering with <?>",
diff --git a/actionpack/test/controller/action_pack_assertions_test.rb b/actionpack/test/controller/action_pack_assertions_test.rb
index 1741b58f72..eae2641dc0 100644
--- a/actionpack/test/controller/action_pack_assertions_test.rb
+++ b/actionpack/test/controller/action_pack_assertions_test.rb
@@ -349,21 +349,43 @@ class ActionPackAssertionsControllerTest < ActionController::TestCase
assert_template :partial => '_partial'
end
- def test_assert_template_with_nil
+ def test_assert_template_with_nil_passes_when_no_template_rendered
get :nothing
assert_template nil
end
- def test_assert_template_with_string
+ def test_assert_template_with_nil_fails_when_template_rendered
+ get :hello_world
+ assert_raise(ActiveSupport::TestCase::Assertion) do
+ assert_template nil
+ end
+ end
+
+ def test_assert_template_passes_with_correct_string
get :hello_world
assert_template 'hello_world'
+ assert_template 'test/hello_world'
end
- def test_assert_template_with_symbol
+ def test_assert_template_passes_with_correct_symbol
get :hello_world
assert_template :hello_world
end
+ def test_assert_template_fails_with_incorrect_string
+ get :hello_world
+ assert_raise(ActiveSupport::TestCase::Assertion) do
+ assert_template 'hello_planet'
+ end
+ end
+
+ def test_assert_template_fails_with_incorrect_symbol
+ get :hello_world
+ assert_raise(ActiveSupport::TestCase::Assertion) do
+ assert_template :hello_planet
+ end
+ end
+
# check if we were rendered by a file-based template?
def test_rendered_action
process :nothing
@@ -387,7 +409,6 @@ class ActionPackAssertionsControllerTest < ActionController::TestCase
assert_nil @response.redirect_url
end
-
# check server errors
def test_server_error_response_code
process :response500