我想模拟此功能:
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)
但是那不起作用。
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
end