diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2012-03-12 10:13:16 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2012-03-12 10:13:16 -0700 |
commit | fd22471313864c58cb911101d8c42e1fa46b4e42 (patch) | |
tree | be7f11a84f404a0d2422231222766e688d134d4a /actionpack/lib | |
parent | dea486d00ed8b9beec767324dfd15bec72d8a1ca (diff) | |
parent | b142bd84d83b222fca393355cdd76416648e5625 (diff) | |
download | rails-fd22471313864c58cb911101d8c42e1fa46b4e42.tar.gz rails-fd22471313864c58cb911101d8c42e1fa46b4e42.tar.bz2 rails-fd22471313864c58cb911101d8c42e1fa46b4e42.zip |
Merge pull request #5375 from nertzy/assert_template_with_regexp
assert_template matches against Regexp
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_controller/test_case.rb | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb index e9a3ec5a22..7af30ed690 100644 --- a/actionpack/lib/action_controller/test_case.rb +++ b/actionpack/lib/action_controller/test_case.rb @@ -56,6 +56,9 @@ module ActionController # # assert that the "new" view template was rendered # assert_template "new" # + # # assert that the exact template "admin/posts/new" was rendered + # assert_template %r{\Aadmin/posts/new\Z} + # # # assert that the "_customer" partial was rendered twice # assert_template :partial => '_customer', :count => 2 # @@ -74,11 +77,11 @@ module ActionController response.body case options - when NilClass, String, Symbol + when NilClass, String, Symbol, Regexp options = options.to_s if Symbol === options rendered = @templates msg = message || sprintf("expecting <%s> but rendering with <%s>", - options, rendered.keys) + options.inspect, rendered.keys) assert_block(msg) do if options rendered.any? { |t,num| t.match(options) } @@ -121,6 +124,8 @@ module ActionController assert @partials.empty?, "Expected no partials to be rendered" end + else + raise ArgumentError, "assert_template only accepts a String, Symbol, Hash, Regexp, or nil" end end end |