[rspec-users] Rails View spec testing for content in <head>
rockrep at gmail.com
Mon Aug 23 12:21:48 EDT 2010
Thank you David. Makes perfect sense.
> The render method you see in a view spec delegates to the render method in ActionView::TestCase, which, in turn, delegates to view.render. Within rails, view.render is called usually by a controller, which provides all the necessary context information, like what layout to render. In this case, because you are specifying things that happen in a layout, you need to provide that context information in the spec:
> render :template => "users/sessions, :layout => "layouts/application"
> Note that you need to include ":template => ..." because RSpec's render method only sets the template if there are no arguments.
More information about the rspec-users