Ruby on rails 我应该如何在芜菁验收规范中加载VCR结果?

Ruby on rails 我应该如何在芜菁验收规范中加载VCR结果?,ruby-on-rails,rspec,vcr,turnip,Ruby On Rails,Rspec,Vcr,Turnip,我有一个web请求,它最终调用外部服务,合并数据库中的数据,然后显示结果 我想我可以忽略一个基于JS的设置(发出请求、队列作业、返回轮询JS),因为如果这是同步的话,我会有同样的问题 step "I do the thing" do fill_in "search", with: "yarp" VCR.use_cassette("some_cassette") do click_on "Do the thing" end end 因此,一旦服务器响应,我们将在html表中

我有一个web请求,它最终调用外部服务,合并数据库中的数据,然后显示结果

我想我可以忽略一个基于JS的设置(发出请求、队列作业、返回轮询JS),因为如果这是同步的话,我会有同样的问题

step "I do the thing" do
  fill_in "search", with: "yarp"

  VCR.use_cassette("some_cassette") do
    click_on "Do the thing"
  end
end
因此,一旦服务器响应,我们将在html表中获取内容,我希望确保外部服务的内容显示在页面上

我找到了这样一种从响应中获取数据的方法,但我想知道是否有更好的方法:

VCR.use_cassette("some_cassette") do |cassette|
  interaction = cassette.serializable_hash["http_interactions"].find do |interaction|
    interaction["request"]["uri"].include?("some_url")
  end

  @raw_result = JSON.parse(interaction["response"]["body"]["string"])
end