[英]stack level too deep in rspec
当我尝试在规格上执行以下代码时,它会使我的stack level too deep
。 在控制台中工作正常。
def order_fulfillments_without_receipts
@order_fulfillments_without_receipts = []
OrderReconciliation.includes(:order_fulfillment).
where(data_entry_status: OrderReconciliation.data_entry_statuses[:pending_entry]).
find_in_batches do |group|
group.select do |reconciliation|
select_reconciliation?(reconciliation)
end
end
@order_fulfillments_without_receipts
end
def select_reconciliation?(reconciliation)
order_fulfillment = reconciliation.order_fulfillment
receipt_urls_empty = order_fulfillment.get_receipt_urls.empty?
order_fulfillment_id = order_fulfillment.id
@order_fulfillments_without_receipts << order_fulfillment_id
receipt_urls_empty || order_fulfillments_without_receipts.include?(order_fulfillment_id)
end
end
我应该如何解决它,以避免stack level too deep
?
您的代码中有错误, select_reconciliation?
最后一行select_reconciliation?
||
之后的方法 您有order_fulfillments_without_receipts
但我认为您的意思是@order_fulfillments_without_receipts
如果没有@
您将调用order_fulfillments_without_receipts
方法,因此将导致无限循环。
为什么在您的测试中而不是在控制台中发生这种情况,必须与每种情况下的receipt_urls_empty
,在测试中它为false
,在控制台中为true
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.