Class: ActionView::TestCase::Behavior::RenderedViewsCollection
- Inherits:
-
Object
- Object
- ActionView::TestCase::Behavior::RenderedViewsCollection
- Defined in:
- lib/action_view/test_case.rb
Instance Method Summary collapse
- #add(view, locals) ⇒ Object
-
#initialize ⇒ RenderedViewsCollection
constructor
A new instance of RenderedViewsCollection.
- #locals_for(view) ⇒ Object
- #rendered_views ⇒ Object
- #view_rendered?(view, expected_locals) ⇒ Boolean
Constructor Details
#initialize ⇒ RenderedViewsCollection
Returns a new instance of RenderedViewsCollection.
124 125 126 |
# File 'lib/action_view/test_case.rb', line 124 def initialize @rendered_views ||= Hash.new { |hash, key| hash[key] = [] } end |
Instance Method Details
#add(view, locals) ⇒ Object
128 129 130 131 |
# File 'lib/action_view/test_case.rb', line 128 def add(view, locals) @rendered_views[view] ||= [] @rendered_views[view] << locals end |
#locals_for(view) ⇒ Object
133 134 135 |
# File 'lib/action_view/test_case.rb', line 133 def locals_for(view) @rendered_views[view] end |
#rendered_views ⇒ Object
137 138 139 |
# File 'lib/action_view/test_case.rb', line 137 def rendered_views @rendered_views.keys end |
#view_rendered?(view, expected_locals) ⇒ Boolean
141 142 143 144 145 |
# File 'lib/action_view/test_case.rb', line 141 def view_rendered?(view, expected_locals) locals_for(view).any? do |actual_locals| expected_locals.all? {|key, value| value == actual_locals[key] } end end |