使用 RSpec 验证部分参数
我需要对一个论点设定期望。如何访问从 RSpec 接收到的参数?
这就是我想要实现的目标。
let(:api) { double('API') }
it "should pass :filter in options" do
api.should_receive(:traverse)
subject.execute
args = api.recevied_arguments_for(:traverse) # How to obtain all the arguments?
args[0].should have_key(:filter)
end
要回答问题,请修复带有注释的行。
谢谢。
I need to set expectation on one single argument. How can I access the received arguments from RSpec?
Here is what I want to achieve.
let(:api) { double('API') }
it "should pass :filter in options" do
api.should_receive(:traverse)
subject.execute
args = api.recevied_arguments_for(:traverse) # How to obtain all the arguments?
args[0].should have_key(:filter)
end
To answer the question, fix the line with the comment.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
刚刚想通了。
比我想象的好多了。
Just figured it out.
Much better than I thought.