Yeah I don’t think you can specify params with the hash syntax, you’ll need to 
use the method.

Jon Rowe
---------------------------
[email protected]
jonrowe.co.uk


On Tuesday, 17 January 2017 at 09:49, Gabriel Zangerl wrote:

> Hey, thx for your answer, but I'm still getting an error
> Api::V1::UsersController routing routes to #index
>      Failure/Error: expect(:get => "/users", :subdomain => 'api').to 
> route_to("api/v1/users#index")
>        No route matches "/users"
>  
>  
>  
> I also tried an other route with /v1/users but thats the same thing:
> Api::V1::UsersController routing routes to #index
>       Failure/Error: expect(:get => "/v1/users", :subdomain => 'api').to 
> route_to("api/v1/users#index")
>         No route matches "/v1/users"
>       # ./spec/routing/users_routing_spec.rb:8:in `block (3 levels) in <top 
> (required)>'
>  
>  
>  
>  
>  
> Am Montag, 16. Januar 2017 23:36:24 UTC+1 schrieb Jon Rowe:
> > I believe you need to use the full `expect(get(‘/users’, :subdomain => 
> > ‘api’)).to route_to("api/v1/users#index”)` to make this work, as RSpec 
> > can’t guess the constraint for you.
> >  
> > Jon Rowe
> > ---------------------------
> > [email protected] (javascript:)
> > jonrowe.co.uk (http://jonrowe.co.uk)
> >  
> >  
> > On Tuesday, 17 January 2017 at 09:24, Gabriel Zangerl wrote:
> >  
> > > Hi everyone,
> > >  
> > > I'm having an Rails 5 --api with Rspec (core) 3.5.4.
> > > The API is working under the subdomain api.mywebsite.com 
> > > (http://api.mywebsite.com).
> > > The Controllers are in an api module and a v1 namespace.
> > >  
> > > Routes look like this:
> > > ...
> > >   constraints subdomain: 'api' do
> > >    scope module: 'api' do
> > >  
> > >       # API v1
> > >      namespace :v1 do
> > >        resources :users, except: :edit
> > >      end
> > >  
> > >    end
> > > end
> > >  
> > >  
> > > Controllers are lying at app/controllers/api/v1 like the 
> > > UsersController.rb:
> > > module Api::V1
> > >   class UsersController < ApplicationController
> > >     def my_methods
> > >       ...
> > >     end
> > >   end
> > > end
> > > In the spec/routing/users_routing.rb I have got e.g.:
> > > require "rails_helper"
> > >  
> > > RSpec.describe Api::V1::UsersController, type: :routing do
> > >   describe "routing" do
> > >         it "routes to #index" do
> > >       expect(:get => "/users").to route_to("api/v1/users#index")
> > >     end
> > >   end
> > > end
> > > But when I call rails spec in the console, I get multiple errors like:
> > > Api::V1::UsersController routing routes to #index
> > >       Failure/Error: expect(:get => "/users").to route_to("users#index")
> > >         No route matches "/users"
> > >       # ./spec/routing/users_routing_spec.rb:8:in `block (3 levels) in 
> > > <top (required)>'
> > >  
> > > Can someone help me here?
> > > Am I missing something??
> > >  
> > > Thx.
> > >  
> > > --  
> > > 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/823c800d-15c8-40a1-a143-5e77a8e27d29%40googlegroups.com
> > >  
> > > (https://groups.google.com/d/msgid/rspec/823c800d-15c8-40a1-a143-5e77a8e27d29%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] 
> (mailto:[email protected]).
> To post to this group, send email to [email protected] 
> (mailto:[email protected]).
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rspec/c8b1ade5-fab2-4abf-b806-3eba3e863057%40googlegroups.com
>  
> (https://groups.google.com/d/msgid/rspec/c8b1ade5-fab2-4abf-b806-3eba3e863057%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/C225B419713749FEA684772CE79C6E5D%40jonrowe.co.uk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to