Argument error when making POST requests
ekampp opened this issue · 2 comments
ekampp commented
Hi there.
I'm getting this exception:
ArgumentError:
unknown keywords: client, case_file
# ./spec/api/v1/public/case_files_spec.rb:13:in `block (3 levels) in <top (required)>'
When running this code:
describe 'POST v1/public/case_files' do
let(:params) do
{
client: attributes_for(:client),
case_file: attributes_for(:case_file),
}
end
it 'creates a client and a case file' do
post 'http://example.com/v1/public/case_files', params # <-- This is line 13
expect_json_types(name: :string)
end
end
against my API. The API is working as expected, and is getting hit if I ommit the params all together. So this seems to be an issue with the syntax.
It should be noted that I'm running a pretty bleeding edge application, so here are a few possible culprits from my Gemfile.lock:
- rspec (3.5.0)
- rspec-core (3.5.4)
- rails (5.1.0.rc1)
Thanks in advance.
benshippee commented
Ran into this also, it looks like you need to explicitly declare the params because of a change in Rails 5.1:
post 'http://example.com/v1/public/case_files', params: params
srghma commented
this is because post
points to rspec post
instead of airborne post
[8] pry(#<RSpec::ExampleGroups::AUTH::RegisteredUser>)> show-method post
From: /usr/local/bundle/gems/rails-controller-testing-0.0.3/lib/rails/controller/testing/integration.rb @ line 10:
Owner: Rails::Controller::Testing::Integration
Visibility: public
Number of lines: 4
define_method(method) do |*args|
reset_template_assertion
super(*args)
end
[9] pry(#<RSpec::ExampleGroups::AUTH::RegisteredUser>)> show-method expect_json
From: /usr/local/bundle/gems/airborne-0.2.13/lib/airborne/request_expectations.rb @ line 17:
Owner: Airborne::RequestExpectations
Visibility: public
Number of lines: 5
def expect_json(*args)
call_with_path(args) do |param, body|
expect_json_impl(param, body)
end
end
[10] pry(#<RSpec::ExampleGroups::AUTH::RegisteredUser>)>