Ruby on rails 用于渲染内联的Rspec:location.reload

Ruby on rails 用于渲染内联的Rspec:location.reload,ruby-on-rails,ruby,rspec,Ruby On Rails,Ruby,Rspec,我的控制器末尾有以下内容 ** some code ** respond_to do |format| format.js {render inline: "location.reload();" } end 我必须为同样的问题编写一个RSPEC expect(response).to render_template(:**what should be given here?**) 或者有没有其他方法来编写RSPEC呢?谢谢您的回复,我知道我们应该指定xhr,而不是get/po

我的控制器末尾有以下内容

** some code **
respond_to do |format|
      format.js {render inline: "location.reload();" }
end
我必须为同样的问题编写一个
RSPEC

 expect(response).to render_template(:**what should be given here?**)

或者有没有其他方法来编写RSPEC呢?

谢谢您的回复,我知道我们应该指定
xhr
,而不是
get/post:method
这就成功了

xhr :post, :schedule_message, params, format: :js
expect(response.body).to eq "location.reload();"

可能重复yea,我在发布此问题之前检查了它,但没有任何想法将其实现到我的代码中。链接帖子中的答案准确地告诉了您需要知道的内容。如果您查看
response.body
,您将得到响应的主体。也就是说,标题之后的所有内容。因此,在本例中,您将获得
location.reload()
作为响应字符串,您可以与之进行比较。