diff options
author | Carlhuda <carlhuda@engineyard.com> | 2010-03-17 14:19:42 -0700 |
---|---|---|
committer | Carlhuda <carlhuda@engineyard.com> | 2010-03-17 14:29:18 -0700 |
commit | 947f86c699b33bd44703b3554db58e4cfca37c86 (patch) | |
tree | 8029a2acf7180b2724830e2727c37252872e436e /actionpack/lib/action_dispatch/testing/assertions | |
parent | 13a783672aad338b9c7ade5319ec7967768905d7 (diff) | |
download | rails-947f86c699b33bd44703b3554db58e4cfca37c86.tar.gz rails-947f86c699b33bd44703b3554db58e4cfca37c86.tar.bz2 rails-947f86c699b33bd44703b3554db58e4cfca37c86.zip |
Modify assert_template to use instrumentation
Diffstat (limited to 'actionpack/lib/action_dispatch/testing/assertions')
-rw-r--r-- | actionpack/lib/action_dispatch/testing/assertions/response.rb | 52 |
1 files changed, 0 insertions, 52 deletions
diff --git a/actionpack/lib/action_dispatch/testing/assertions/response.rb b/actionpack/lib/action_dispatch/testing/assertions/response.rb index 937c9f48d2..ec5e9efe44 100644 --- a/actionpack/lib/action_dispatch/testing/assertions/response.rb +++ b/actionpack/lib/action_dispatch/testing/assertions/response.rb @@ -73,58 +73,6 @@ module ActionDispatch end end - # Asserts that the request was rendered with the appropriate template file or partials - # - # ==== Examples - # - # # assert that the "new" view template was rendered - # assert_template "new" - # - # # assert that the "_customer" partial was rendered twice - # assert_template :partial => '_customer', :count => 2 - # - # # assert that no partials were rendered - # assert_template :partial => false - # - def assert_template(options = {}, message = nil) - validate_request! - - case options - when NilClass, String - rendered = (@controller.template.rendered[:template] || []).map { |t| t.identifier } - msg = build_message(message, - "expecting <?> but rendering with <?>", - options, rendered.join(', ')) - assert_block(msg) do - if options.nil? - @controller.template.rendered[:template].blank? - else - rendered.any? { |t| t.match(options) } - end - end - when Hash - if expected_partial = options[:partial] - partials = @controller.template.rendered[:partials] - if expected_count = options[:count] - found = partials.detect { |p, _| p.identifier.match(expected_partial) } - actual_count = found.nil? ? 0 : found.second - msg = build_message(message, - "expecting ? to be rendered ? time(s) but rendered ? 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 <?>", - options[:partial], partials.keys) - assert(partials.keys.any? { |p| p.identifier.match(expected_partial) }, msg) - end - else - assert @controller.template.rendered[:partials].empty?, - "Expected no partials to be rendered" - end - end - end - private # Proxy to to_param if the object will respond to it. def parameterize(value) |