aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Chelimsky <dchelimsky@gmail.com>2010-04-29 08:18:47 -0500
committerJosé Valim <jose.valim@gmail.com>2010-05-03 13:46:12 +0200
commit849ab9294244ac94f9ce4621c8cd325a2992a382 (patch)
tree5d3059b82714c1bb14119c6e1838ea9d2ee8c071
parent36fc489aa3086e384db9f13390f01246d006e47e (diff)
downloadrails-849ab9294244ac94f9ce4621c8cd325a2992a382.tar.gz
rails-849ab9294244ac94f9ce4621c8cd325a2992a382.tar.bz2
rails-849ab9294244ac94f9ce4621c8cd325a2992a382.zip
Eliminate false positives when passing symbols to assert_template
Signed-off-by: José Valim <jose.valim@gmail.com>
-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