rocket_pants
rocket_pants copied to clipboard
Route cannot be generated in Rspec 3
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?
Still having this problem, @Sutto any idea?
Try that (allow_prefix
):
api versions: 1, allow_prefix: 'v', module: "api/v1" do
resources :projects, only: [:index, :show, :create, :update]
end
I kinda gave up on RocketPants due to this, so someone else will have to try this out.
@manuelmeurer What gem/solution are you using?
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.
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 :()
I ran into the same situation. Any updates here?
Same here.
I'm having a similar problem with InvalidVersion exception being raised. I've tried everything and can't figure out the cause.
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 ;) :tada: