[rspec-devel] [ rspec-Bugs-6895 ] should_render :action doesn't seem to work

noreply at rubyforge.org noreply at rubyforge.org
Sun Nov 26 19:07:27 EST 2006


Bugs item #6895, was opened at 2006-11-26 23:27
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=6895&group_id=797

Category: rails plugin
Group: None
Status: Closed
Resolution: Rejected
Priority: 3
Submitted By: Pat Maddox (pergesu)
Assigned to: David Chelimsky (dchelimsky)
Summary: should_render :action doesn't seem to work

Initial Comment:
0.7.3, edge rails, if I do

  specify "should show the form" do
    controller.should_render :action => "new"
  end

Then I get {:action=>"new"} should == {:template=>"people/new"}.  Doing should_render :template => "people/new" works fine.

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

>Comment By: David Chelimsky (dchelimsky)
Date: 2006-11-27 00:07

Message:
I'm sorry you don't like that, Pat. I think we have different visions of this. Let me explain where we're coming from on this.

The controller's responsibility is to interact with the model and the view, and we want to be able to specify how the controller should fulfill that responsibility. Based on that thinking, the things that belong in the controller spec are interactions with the model (in the form of mock expectations set on the model) and interactions with the view (in the form of what should get assigned and what template should ultimately be rendered).

Specifying that "get 'new'" causes the "new" method (or action) to be invoked is specifying that Rails works correctly, which is not something that we care about in a controller spec. Of course, there is custom routing to consider, but you can handle that with routing specs.

Additionally, view specs allow you to specify what a view (template) does with the data you feed it. It has absolutely nothing to do with what controller or action invoked it.

Hope this makes sense to you.

Cheers,
David


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

Comment By: Pat Maddox (pergesu)
Date: 2006-11-26 23:53

Message:
I don't like that.  The current setup is to spec controllers
separately from views.  As such, we should specify that the
request renders the result of a particular action, rather
than a specific template.  The template belongs to the view
spec.

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

Comment By: David Chelimsky (dchelimsky)
Date: 2006-11-26 23:49

Message:
That's how this is supposed to work. This is really a documentation issue.

The only time you would use :action is if you were redirecting to another action. Otherwise you should use :template => ...

I've added a documentation request for this:

http://rubyforge.org/tracker/index.php?group_id=797&atid=9738

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

Comment By: Pat Maddox (pergesu)
Date: 2006-11-26 23:44

Message:
The controller code is the very simple

  def new
    @person = Person.new
  end

with a corresponding new.rhtml file.

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

Comment By: David Chelimsky (dchelimsky)
Date: 2006-11-26 23:36

Message:
What is in the controller code?

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

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


More information about the rspec-devel mailing list