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

Inherits:
Object
  • Object
show all
Defined in:
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.



305
306
307
# File 'lib/action_view/test_case.rb', line 305

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

Instance Method Details

#add(view, locals) ⇒ Object



309
310
311
312
# File 'lib/action_view/test_case.rb', line 309

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

#locals_for(view) ⇒ Object



314
315
316
# File 'lib/action_view/test_case.rb', line 314

def locals_for(view)
  @rendered_views[view]
end

#rendered_viewsObject



318
319
320
# File 'lib/action_view/test_case.rb', line 318

def rendered_views
  @rendered_views.keys
end

#view_rendered?(view, expected_locals) ⇒ Boolean

Returns:

  • (Boolean)


322
323
324
325
326
# File 'lib/action_view/test_case.rb', line 322

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