Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/61.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails RSpec在get请求时指定标头_Ruby On Rails_Ruby_Rspec_Http Headers - Fatal编程技术网

Ruby on rails RSpec在get请求时指定标头

Ruby on rails RSpec在get请求时指定标头,ruby-on-rails,ruby,rspec,http-headers,Ruby On Rails,Ruby,Rspec,Http Headers,我正在RSpec上执行以下get请求: get "api/posts/#{@post.id}?api_key=#{Settings.api_key.android}&device_token=#{@device.token}&auth_token=#{@user.authentication_token}" 我需要指定标题 在“邮递员”上,我的标题如下所示: 如何在RSpec上将我的头添加到get请求中 我试过这个: get "api/posts/#{@post.id}?api

我正在RSpec上执行以下get请求:

get "api/posts/#{@post.id}?api_key=#{Settings.api_key.android}&device_token=#{@device.token}&auth_token=#{@user.authentication_token}"
我需要指定标题

在“邮递员”上,我的标题如下所示:

如何在RSpec上将我的头添加到get请求中

我试过这个:

get "api/posts/#{@post.id}?api_key=#{Settings.api_key.android}&device_token=#{@device.token}&auth_token=#{@user.authentication_token}", nil, {'ACCEPT' => 'application/vdn.foo.v10'} 
没有任何成功

任何帮助都将不胜感激

看下面的答案。您还可以使用
request
变量访问请求,并直接在那里操作头