Class ActionView::Base
In: lib/test/rails/render_tree.rb
Parent: Object

test/rails/render_tree.rb adds debug rendering to ActionView::Base#render.

Debug rendering prints out a tree of calls to render allowing you to easily visualize where rendering occurs in unfamiliar code.

Methods

render  

Constants

RENDERS = [:partial, :template, :file, :action, :text, :inline, :nothing, :update]   List of render types for ActionView::Base#render

External Aliases

render -> plain_render

Public Instance methods

Add debug output to rendering.

When you include lib/rails/render_tree a tree of renders will be displayed in the console. This is especially useful when writing tests.

This test:

  require 'test/test_helper'
  require 'test/rails/render_tree'

  class ThingsViewTest < Test::Rails::ViewTestCase

    fixtures :goals

    def test_body
      assigns[:goal] = goals(:first)
      assigns[:related_goals_moved] = []
      assigns[:related_goals_instead] = []

      render :partial => 'things/body'

      assert_tag :tag => 'div', :attributes => { :id => 'entriesbucket' }
    end

  end

Will give this output when run:

  $ ruby test/views/things_view_test.rb -n test_body
  Loaded suite test/views/things_view_test
  Started
  "things/_body"
    :partial => "widgets/goals_gallery_teaser"
      "widgets/_goals_gallery_teaser"
    :partial => "entries_bucket"
      "things/_entries_bucket"
    :partial => "things/ask_a_question"
      "things/_ask_a_question"
    "widgets/forms/related_goals"
  .
  Finished in 1.293523 seconds.

  1 tests, 1 assertions, 0 failures, 0 errors

[Validate]