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

Jarkko Laine jarkko at jlaine.net
Tue Oct 2 03:18:17 EDT 2007

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.


Jarkko Laine

More information about the rspec-users mailing list