aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorGrant Hutchins <nertzy@gmail.com>2012-03-10 19:25:12 -0500
committerGrant Hutchins <nertzy@gmail.com>2012-03-10 19:25:12 -0500
commitb142bd84d83b222fca393355cdd76416648e5625 (patch)
tree51c7eb391730286eaf878c0bd5f641c8b431a7e9 /actionpack/test
parentd5d241cb2c696f13e2c16efca0d24565a6e1c0a5 (diff)
downloadrails-b142bd84d83b222fca393355cdd76416648e5625.tar.gz
rails-b142bd84d83b222fca393355cdd76416648e5625.tar.bz2
rails-b142bd84d83b222fca393355cdd76416648e5625.zip
assert_template matches against Regexp
This allows for more strict template assertions, while maintaining backward compatibility. For example, if you use assert_template("foo/bar") and "foo/bar/baz" was rendered, the test passes. But if you use assert_template(%r{\Afoo/bar\Z}), you will catch that a different template was rendered. Also, if you passed an unsupported argument to assert_template() in the past, it would silently succeed. Now it raises an ArgumentError.
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/template/test_case_test.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/actionpack/test/template/test_case_test.rb b/actionpack/test/template/test_case_test.rb
index 37858c1ba2..f2ed2ec609 100644
--- a/actionpack/test/template/test_case_test.rb
+++ b/actionpack/test/template/test_case_test.rb
@@ -277,6 +277,12 @@ module ActionView
end
class RenderTemplateTest < ActionView::TestCase
+ test "supports specifying templates with a Regexp" do
+ controller.controller_path = "fun"
+ render(:template => "fun/games/hello_world")
+ assert_template %r{\Afun/games/hello_world\Z}
+ end
+
test "supports specifying partials" do
controller.controller_path = "test"
render(:template => "test/calling_partial_with_layout")