diff options
author | Yves Senn <yves.senn@gmail.com> | 2012-10-09 21:14:11 +0200 |
---|---|---|
committer | Yves Senn <yves.senn@garaio.com> | 2012-10-11 08:47:10 +0200 |
commit | d6524d78687b39c72e0814e61b80e3e6b6d9997e (patch) | |
tree | b7400c5569e4f718e42f10a2c964b16331bcac2c /actionpack/lib/action_controller | |
parent | ed9567401dfc7b476bf9ccac82826fc63283f708 (diff) | |
download | rails-d6524d78687b39c72e0814e61b80e3e6b6d9997e.tar.gz rails-d6524d78687b39c72e0814e61b80e3e6b6d9997e.tar.bz2 rails-d6524d78687b39c72e0814e61b80e3e6b6d9997e.zip |
refactor `ActionView::TestCase` internals to track rendered locals
this refactoring extracts the semi complex data structure of rendered locals
per view into into a separate class
Diffstat (limited to 'actionpack/lib/action_controller')
-rw-r--r-- | actionpack/lib/action_controller/test_case.rb | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb index 6aa43edf47..d911d47a1d 100644 --- a/actionpack/lib/action_controller/test_case.rb +++ b/actionpack/lib/action_controller/test_case.rb @@ -123,17 +123,12 @@ module ActionController if expected_partial = options[:partial] if expected_locals = options[:locals] - if defined?(@_locals) - actual_locals_collection = @_locals[expected_partial.to_s.sub(/^_/,'')] - result = actual_locals_collection.any? do |actual_locals| - expected_locals.each_pair.all? do |k,v| - v == actual_locals[k] - end - end + if defined?(@_rendered_views) + view = expected_partial.to_s.sub(/^_/,'') msg = 'expecting %s to be rendered with %s but was with %s' % [expected_partial, expected_locals, - actual_locals_collection] - assert(result, msg) + @_rendered_views.locals_for(view)] + assert(@_rendered_views.view_rendered?(view, options[:locals]), msg) else warn "the :locals option to #assert_template is only supported in a ActionView::TestCase" end |