Rspec发布请求rails 5

时间:2017-05-31 15:41:25

标签: ruby-on-rails rspec ruby-on-rails-5 grape-api

我想使用api/v1/posts

rspec测试我的创建操作

api是使用grape

构建的

所以我试过了

    post 'api/v1/posts', params: { post: { name: 'name', body: 'body', published_at: Date.today } }

但我有

ArgumentError: wrong number of arguments (given 2, expected 0)

完整错误跟踪

params = { name: 'name', body: 'body', published_at: Date.today }        
=> {:name=>"name", :body=>"body", :published_at=>Wed, 31 May 2017}

[91] pry(#<RSpec::ExampleGroups::APIV1Posts::Anonymous::HTTPRequestToPostAPI>)> post 'api/v1/posts', params: params        
ArgumentError: wrong number of arguments (given 2, expected 0)

from /Users/stas/.rvm/gems/ruby-2.4.1/gems/rspec-core-3.6.0/lib/rspec/core/memoized_helpers.rb:298:in `block in let'

如何解决?

0 个答案:

没有答案