ruby on rails - RSpec Post with a file, params and header field -


i trying test out api using rspec uploading file. api request simple post request file along params , header field.

i tried making post request following code:

post "media.upload", { client_id: @client.id, token: @client.token, type: @type, name: @name, format: 'json' }, { 'http_proxy_ssl' => 'true' }, :upload => @file 

but following error:

failure/error: post "cm/media.upload", { client_id: @client.id, token: @client.token, type: @type, name: @name, format: 'json' },      argumenterror:        wrong number of arguments (4 1..3) 

the @file variable defined as:

@file = fixture_file_upload(rails.root + 'spec/fixtures/images/abc.jpg', 'image/jpeg') 

so question how post request in rspec file, parameters , headers?

move upload param in rest of request params:

params = {upload: @file, client_id: @client.id, token: @client.token, type: @type, name: @name, format: 'json'} headers = {'http_proxy_ssl' => 'true'}  post 'media.upload', params, headers 

Comments

Popular posts from this blog

php - Zend Framework / Skeleton-Application / Composer install issue -

c# - Better 64-bit byte array hash -

python - PyCharm Type error Message -