[rspec-users] Problems with testing nested routes using mocking

David Chelimsky dchelimsky at gmail.com
Tue Oct 2 03:21:07 EDT 2007


On 10/2/07, Jarkko Laine <jarkko at jlaine.net> wrote:
> On 2.10.2007, at 1.33, Jesper Laursen wrote:
> > It know work in a browser, but if i am
> > running autotest, this error raise:
> >
> > <cite>
> > /opt/local/bin/ruby -S script/spec -O spec/spec.opts
> > spec/views/virtual_hosts/show.rhtml_spec.rb
> > F
> >
> > 1)
> > ActionView::TemplateError in '/virtual_hosts/show.rhtml should render
> > attributes in <p>'
> > edit_virtual_host_url failed to generate from
> > {:controller=>"virtual_hosts", :domain_id=>"1001", :action=>"edit"},
> > expected: {:controller=>"virtual_hosts", :action=>"edit"}, diff:
> > {:domain_id=>"1001"}
> > On line #92 of app/views/virtual_hosts/show.rhtml
> >
> >     89: </p>
> >     90:
> >     91:
> >     92: <%= link_to 'Edit', edit_virtual_host_path(@virtual_host) %> |
>
> I've stumbled upon something similar. I'm using Globalize and setting
> the language parameter in a path_prefix: /en/users/1, etc. Rails
> itself can pass the language parameter to the REST routes
> automatically, so I can just say user_path(@user). However, all the
> view specs bomb just like they do here, and I'm forced to say
> user_path(:language_id => "en", :id => @user) just to make the specs
> pass, which is both laborious, error-prone and ugly.

This is a known issue:

http://rubyforge.org/tracker/index.php?func=detail&aid=12963&group_id=797&atid=3149

Patches welcome!

>
> //jarkko
>
> --
> Jarkko Laine
> http://jlaine.net
> http://dotherightthing.com
> http://www.railsecommerce.com
> http://odesign.fi
>
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list