[rspec-devel] [ rspec-Bugs-11536 ] controller.should render_template must be defined after the action

noreply at rubyforge.org noreply at rubyforge.org
Tue Jun 12 18:25:20 EDT 2007


Bugs item #11536, was opened at 2007-06-12 22:25
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=11536&group_id=797

Category: rails plugin
Group: None
Status: Open
Resolution: None
Priority: 3
Submitted By: courtenay 3 (court3nay)
Assigned to: Nobody (None)
Summary: controller.should render_template must be defined after the action

Initial Comment:
this fails:

  it "should render index.rhtml" do
    response.should render_template(:index)
    do_get
  end

this works:

  it "should render index.rhtml" do
    do_get
    response.should render_template(:index)
  end

Here's my patch; it doesn't "feel" right to me, since there's no other error handling in that file.

Index: lib/spec/rails/matchers/render_template.rb
===================================================================
--- lib/spec/rails/matchers/render_template.rb  (revision 1429)
+++ lib/spec/rails/matchers/render_template.rb  (working copy)
@@ -9,6 +9,9 @@
         end
       
         def matches?(response)
+          unless response.respond_to?:rendered_file
+            raise "The response has not yet rendered or is not a Response object. This matcher (render_template) must be defined after the controller action is called."
+          end
           @actual = response.rendered_file(!expected.include?('/'))
           actual == expected
         end


----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=11536&group_id=797


More information about the rspec-devel mailing list