lib/spec/rails/matchers/render_template.rb in dchelimsky-rspec-rails-1.1.11 vs lib/spec/rails/matchers/render_template.rb in dchelimsky-rspec-rails-1.1.11.1
- old
+ new
@@ -51,34 +51,44 @@
def current_controller_path
@controller.class.to_s.underscore.gsub(/_controller$/,'')
end
end
-
+
# :call-seq:
- # response.should render_template(path)
- # response.should_not render_template(path)
+ # response.should render_template(template)
+ # response.should_not render_template(template)
#
- # Passes if the specified template is rendered by the response.
- # Useful in controller specs (integration or isolation mode).
+ # For use in controller code examples (integration or isolation mode).
#
- # <code>path</code> can include the controller path or not. It
- # can also include an optional extension (no extension assumes .rhtml).
+ # Passes if the specified template (view file) is rendered by the
+ # response. This file can be any view file, including a partial. However
+ # if it is a partial it must be rendered directly i.e. you can't detect
+ # that a partial has been rendered as part of a view using
+ # render_template. For that you should use a message expectation
+ # (mock) instead:
#
+ # controller.should_receive(:render).with(:partial => 'path/to/partial')
+ #
+ # <code>template</code> can include the controller path. It can also
+ # include an optional extension, which you only need to use when there
+ # is ambiguity.
+ #
# Note that partials must be spelled with the preceding underscore.
#
# == Examples
#
# response.should render_template('list')
# response.should render_template('same_controller/list')
# response.should render_template('other_controller/list')
#
- # #rjs
+ # # with extensions
# response.should render_template('list.rjs')
+ # response.should render_template('list.haml')
# response.should render_template('same_controller/list.rjs')
# response.should render_template('other_controller/list.rjs')
#
- # #partials
+ # # partials
# response.should render_template('_a_partial')
# response.should render_template('same_controller/_a_partial')
# response.should render_template('other_controller/_a_partial')
def render_template(path)
RenderTemplate.new(path.to_s, @controller)