Skip to content

Instantly share code, notes, and snippets.

@xunker
Created September 6, 2012 18:32
Show Gist options
  • Save xunker/3659267 to your computer and use it in GitHub Desktop.
Save xunker/3659267 to your computer and use it in GitHub Desktop.
Question about Rspec post with rocket_pants

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.

@xunker
Copy link
Author

xunker commented Sep 10, 2012

Thanks for your insight, after placing the :version symbol in proper place it is working now. I have forked + updated the readme to mention the post syntax and the default_version flag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment