Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Route cannot be generated in Rspec 3 #108

Open
manuelmeurer opened this issue Jul 23, 2014 · 10 comments
Open

Route cannot be generated in Rspec 3 #108

manuelmeurer opened this issue Jul 23, 2014 · 10 comments

Comments

@manuelmeurer
Copy link
Contributor

I'm using Rocket Pants 1.10.0 with Rails 4.1.4 and Rspec 3.0.0. With previous Rspec version this worked:

describe API::V1::AccountsController do
  default_version 1

  describe 'POST create' do
    it 'works' do
      post :create
    end
  end
end

Now I get this error:

ActionController::UrlGenerationError:
No route matches {:action=>"create", :controller=>"api/v1/accounts", :version=>"1"}

When I change default_version 1 to default_version 'v1', the route is generated but in the log file it says:

Processing by API::V1::AccountsController#create as 
  Parameters: {"version"=>"v1"}
Exception raised: RocketPants::InvalidVersion: RocketPants::InvalidVersion

Relevant part of my routes.rb:

namespace :api, path: '', constraints: { subdomain: 'api' } do
  api version: 1, require_prefix: 'v', module: 'v1' do
    resource :account, only: :create
  end
end

Any idea what might cause this?

@manuelmeurer
Copy link
Contributor Author

Still having this problem, @Sutto any idea?

@fsmanuel
Copy link
Contributor

Try that (allow_prefix):

api versions: 1, allow_prefix: 'v', module: "api/v1" do
  resources :projects,        only: [:index, :show, :create, :update]
end

@manuelmeurer
Copy link
Contributor Author

I kinda gave up on RocketPants due to this, so someone else will have to try this out.

@fsmanuel
Copy link
Contributor

@manuelmeurer What gem/solution are you using?

@manuelmeurer
Copy link
Contributor Author

I was looking at https://github.com/rails-api/rails-api but since I need HTML rendering too, I'll probably go with regular Rails.

@Sutto
Copy link
Owner

Sutto commented May 20, 2015

Sorry guys - I feel like this is a bigger part of an issue and forgot about it quite a while ago, quite by accident. It'll be looked into again in the near future, and hopefully I can work out the correct solution then. Thanks! (and sorry :()

@ben-ole
Copy link

ben-ole commented Jul 5, 2015

I ran into the same situation. Any updates here?

@strux
Copy link

strux commented Aug 19, 2015

Same here.

@avitus
Copy link

avitus commented Feb 9, 2016

I'm having a similar problem with InvalidVersion exception being raised. I've tried everything and can't figure out the cause.

@mbhnyc
Copy link
Contributor

mbhnyc commented Jul 6, 2016

Hmm I may be running into this as well, hitting it during testing getting:
No route matches {:action=>"confirm", :controller=>"api/people", :version=>"3", :work_email=>"xxx"}

I would expect the controller params to be api/v3/people?

generated routes look correct: api/v3/people#confirm_email {:format=>"json", :version=>/(3)/}

Ah duh - fixed - when moving controllers around, don't forget to move your tests into the new module folder ;) 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants