I have a helper used for views which calls url_for(controller: 
'controller_name', action: :index) and my rake route for the controller 
looks like this:

              Prefix Verb URI Pattern                                     
Controller#Action

user_gadgets GET  /users/:user_id/gadgets(.:format)     gadgets#index

 user_gadget GET  /users/:user_id/gadgets/:id(.:format) gadgets#show

I provided the both id and user_id in params by method stub:
allow(view).to receive(:params).and_return(user_id: 'test-id', id: 'id_1')

But it still throws the same error. Thanks :)

On Tuesday, February 2, 2016 at 4:25:12 AM UTC+5:30, Jon Rowe wrote:
>
> Yes, you need to provide `:user_id` in your params for the route to match. 
> You can see this by running `rake routes` which will show you the 
> parameters required for each route.
>
> Jon Rowe
> ---------------------------
> [email protected] <javascript:>
> jonrowe.co.uk
>
> On Tuesday, 2 February 2016 at 03:12, Tenzin Chemi wrote:
>
> I have a nested resources in my route, is it because of that?
>
>   resources :users, only: [:index, :show] do
>     resources :gadgets, only: [:index, :show]
>   end
>
>
>
>
> On Sunday, January 31, 2016 at 5:39:32 AM UTC+5:30, Jon Rowe wrote:
>
> Without seeing your routes file it’s hard to guess what’s going wrong 
> here, the common scenarios for this involve not giving rspec required parts 
> of the route, (for example params for any scoping you’ve applied to the 
> route, e.g. if the route is company/:id/gadgets you need to provide the 
> company id into the params) that would be present in the view by default
>
> Jon Rowe
> ---------------------------
> [email protected]
> jonrowe.co.uk
>
> On Friday, 29 January 2016 at 19:11, Tenzin Chemi wrote:
>
>  I am getting no route matches error when I test a view which uses 
> #url_for. My application runs fine when I load the view but rspec tests 
> can't find the route. I don't want to mock #url_for. 
>
> Is there a way to make this work without mocking? Thanks in advance.
>
>
>
> 1) shared/menu when auth is disabled displays 
>      Failure/Error: render template: 'shared/_menu'
>
>     ActionView::Template::Error:
>
>       No route matches {:action=>"index", :controller=>"gadgets"}
>
>     # 
> /Users/tc/.rvm/gems/ruby-2.2.3/gems/actionpack-4.2.4/lib/action_dispatch/journey/formatter.rb:46:in
>  
> `generate'
>
>     # 
> /Users/tc/.rvm/gems/ruby-2.2.3/gems/actionpack-4.2.4/lib/action_dispatch/routing/route_set.rb:729:in
>  
> `generate'
>
>     # 
> /Users/tc/.rvm/gems/ruby-2.2.3/gems/actionpack-4.2.4/lib/action_dispatch/routing/route_set.rb:760:in
>  
> `generate'
>
>     # 
> /Users/tc/.rvm/gems/ruby-2.2.3/gems/actionpack-4.2.4/lib/action_dispatch/routing/route_set.rb:803:in
>  
> `url_for'
>
>     # 
> /Users/tc/.rvm/gems/ruby-2.2.3/gems/actionpack-4.2.4/lib/action_dispatch/routing/url_for.rb:156:in
>  
> `url_for'
>
>     # 
> /Users/tc/.rvm/gems/ruby-2.2.3/gems/actionview-4.2.4/lib/action_view/routing_url_for.rb:94:in
>  
> `url_for'
>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "rspec" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rspec/884080c5-7dc2-4e89-b3d8-7dfa7916a586%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/rspec/884080c5-7dc2-4e89-b3d8-7dfa7916a586%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "rspec" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] <javascript:>.
> To post to this group, send email to [email protected] <javascript:>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rspec/79ddc31c-2060-4134-8e71-09a83aa358b9%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/rspec/79ddc31c-2060-4134-8e71-09a83aa358b9%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rspec/bfca9f42-3a68-4bc3-9432-1c963d57e96a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to