[rspec-users] How to test views with Nested Resources and Partials

Jarkko Laine jarkko at jlaine.net
Wed Nov 21 02:12:04 EST 2007


Hi Troy,

On 20.11.2007, at 22.21, Troy Nini wrote:
> ########     Output from running edit.haml_spec.r     ########
>
> F
>
> 1)
> ActionView::TemplateError in '/line_items/edit.haml should render  
> edit form'
> contract_line_item_url failed to generate from  
> {:contract_id=>"1", :action=>"show", :controller=>"line_items"},  
> expected: {:action=>"show", :controller=>"line_items"}, diff:  
> {:contract_id=>"1"}
> On line #6 of app/views/line_items/edit.haml
>
>     3:
>     4: #section1
>     5:   = error_messages_for :line_item
>     6:   - form_for(:line_item, :url => contract_line_item_path 
> (@contract.id)

contract_line_item_path (and _url) expects two parameters, contract  
and line item (or their ids). The errors the routing code outputs are  
often pretty cryptic.

//jarkko

--
Jarkko Laine
http://jlaine.net
http://dotherightthing.com
http://www.railsecommerce.com
http://odesign.fi




More information about the rspec-users mailing list