【发布时间】:2019-01-24 01:36:10
【问题描述】:
我正在尝试模拟Open3.capture2,我想返回一个字符串和一个双精度值作为状态。知道如何返回 2 值吗?
待测代码:
stdout, status = Open3.capture2(command)
if status.success?
puts stdout
else
puts stdout
throw "error: could not execute"
end
规格:
it "throws an error" do
status = double("status message", :success? => false)
allow(Open3).to receive(:capture2).and_return("wat?", status)
ScreenShotWorker.new.perform(url: "www.google.com")
expect(Open3).to have_received(:capture2)
end
【问题讨论】:
标签: ruby-on-rails ruby rspec ruby-on-rails-5