I know you have to supply { :version => nnn } with each, but either that doesn't work with post or the post method is getting confused about which argument is the version number and which is the post payload. Didn't see anything in the docs about post(), only get() with rspec.
First, here are my routes:
api :version => 1 do
resource :authenticate, :controller => "authenticate", :only => [ :show, :create, :update, :destroy ]
end
Now, the code I am having problems with. I want to simulate a post, so doing:
post :create, :version => 1, { :email => 'some@email.com', :password => 'some_password' }
..returns:
syntax error, unexpected '\n', expecting tASSOC (SyntaxError)
Similarly, doing:
post :create, { :email => 'some@email.com', :password => 'some_password' }, :version => 1
..returns:
ActionController::RoutingError: No route matches {:email=>"some@email.com", :password=>"some_password", :controller=>"authenticate", :action=>"create"}
What is the syntax for a post in rspec with RP? The standard rails/rspec syntax doesn't appear to work, or I am missing something.
I believe the error it gives is an issue in the controller possibly (it's a parser error on some file) - so rails bails out generating the route since it needs to read the controller to render the route (I'd double check -
ruby -c path/to/your/file
should help there.Ideally, version should be in the hash as the email / password params though - it is just a normal param. Doing that may also solve the problem. The other thing to consider there is using the
default_version
macro, e.g: