ruby - PUT method return 405 in RSpec test for API -


i building restful web server using goliath-grape , using rspec tdd. when make api put call (/api/v1/users/:id) update existing record browser expected 204 response.

but when test same api call through rspec 405. , response header looks this:

put /api/v1/users/:id {"allow"=>"options, post, get, head", "content_type"=>"text/plain", "content_length"=>"0", "server"=>"goliath", "date"=>"fri, 09 aug 2013 01:37:09 gmt"} 

code snippet api_spec.rb

describe "put /api/v1/users/:id"   "update user , return 204"     with_api(application, api_options)       put_request(:path => "/api/v1/users/#{user_id}", :body => '{"user": {"email": "test_again@example.com"}', :head => {'content-type' => 'application/json'}) |c|         # .....       end     end   end end 

code snippet update method:

# update put "/:id"   if user.where(_id: params['id']).exists?     user.where(_id: params['id']).update(params['user'])     status(204)   else     error! "bad request", 400   end end 

any idea why breaking in rspec test.

thanks

please check:

use goliath::rack::validation::requestmethod, %w(get post put delete) 

Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -