Testing render calls in view helpers

expectationgap Posted by expectationgap on November 08, 2011

Consider the following view helper:

def widget_renderer(some_value)
  if some_value
    render :partial => 'widget_a'
  else
    render :partial => 'widget_b'
  end
end

How do you test that helper method?

If you write a normal view_helper_test - as the test case is run it will try to render the partial, fail to find it, and finally error out. I realize that you can write a functional/integration level test that can assert that the right partial was rendered, but I was hoping for a clean way to test the helper method directly.

Answers

Fork me on GitHub