#49 √ wontfix
Chad Humphries

[#11536] controller.should render_template must be defined after the action

Reported by Chad Humphries | November 19th, 2007 @ 04:17 AM

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

Comments and changes to this ticket

  • Chad Humphries

    Chad Humphries November 19th, 2007 @ 04:17 AM

    Date: 2007-09-12 03:22

    Sender: David Chelimsky

    It's a bit too late for that Bryan. We're committed to not changing

    these. We could alias it, but I'd prefer to avoid going down

    that path. I think we need to figure out a way to give the right

    feedback when it's used incorrectly.

    Date: 2007-09-12 03:14

    Sender: Bryan Helmkamp

    Perhaps the matcher should be renamed from render_file to

    have_rendered_file. Thoughts?

    If this sounds good, I'll write a patch.

    Date: 2007-06-12 18:34

    Sender: courtenay 3

    the patch doesn't actually work like I intended, but I can't

    see a way of checking

    that the order is correct

  • David Chelimsky

    David Chelimsky July 19th, 2008 @ 04:11 AM

      • → State changed from “new” to “wontfix”
      • → Tag changed from “” to “bug”

Please Login or create a free account to add a new comment.

You can update this ticket by sending an email to from your email client. (help)

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Behaviour Driven Development for Ruby.

Shared Ticket Bins

People watching this ticket

Tags