我想模拟这个函数:
def self.set_segment_info(segment_info, history_record)
history_record.segment_info = segment_info
end
在我的测试中,我想要一个仅确认我使用期望值调用了set_segment_info的模拟。我不关心我传递给history_record的是什么。
我该怎么做呢?我试过了
SegmentHistoryRecord.expects(:set_segment_info).with(:segment_info => expected_segment_info, :history_record => anything)但这并不管用。
发布于 2020-03-06 12:10:09
SegmentHistoryRecord.expects(:set_segment_info).with() do |param1, param2|
# change below to your verification for :segment_info
# and leave param2 doing nothing, the expectation will ignore param2
param1 == expected_segment_info
endhttps://stackoverflow.com/questions/60555588
复制相似问题