Class: ActionView::TestCase::Behavior::RenderedViewsCollection

Inherits:
Object
  • Object
show all
Defined in:
actionview/lib/action_view/test_case.rb

Overview

Need to experiment if this priority is the best one: rendered => output_buffer

Instance Method Summary collapse

Constructor Details

#initializeRenderedViewsCollection

Returns a new instance of RenderedViewsCollection.



135
136
137
# File 'actionview/lib/action_view/test_case.rb', line 135

def initialize
  @rendered_views ||= Hash.new { |hash, key| hash[key] = [] }
end

Instance Method Details

#add(view, locals) ⇒ Object



139
140
141
142
# File 'actionview/lib/action_view/test_case.rb', line 139

def add(view, locals)
  @rendered_views[view] ||= []
  @rendered_views[view] << locals
end

#locals_for(view) ⇒ Object



144
145
146
# File 'actionview/lib/action_view/test_case.rb', line 144

def locals_for(view)
  @rendered_views[view]
end

#rendered_viewsObject



148
149
150
# File 'actionview/lib/action_view/test_case.rb', line 148

def rendered_views
  @rendered_views.keys
end

#view_rendered?(view, expected_locals) ⇒ Boolean

Returns:

  • (Boolean)


152
153
154
155
156
# File 'actionview/lib/action_view/test_case.rb', line 152

def view_rendered?(view, expected_locals)
  locals_for(view).any? do |actual_locals|
    expected_locals.all? { |key, value| value == actual_locals[key] }
  end
end