当示例到达 break 语句时,我遇到了 LocalJumpError 的问题。有谁知道如何存根break
,或者这是否是正确的方法?
方法:
def foo(file_name, limit)
CSV.foreach(file_name, col_sep: "|") do |row|
row_count += 1
do something...
break if row_count >= limit
end
end
规格:
it 'does not exceed the limit' do
CSV.should_receive(:foreach).with(file_name, col_sep: "|") do |&block|
block.call(header_fields)
block.call(data)
end
foo(file_name, 2)
end