2016-10-25 4 views
0

仕様上次のコードを実行しようとすると、stack level too deepと表示されます。コンソールで正常に動作します。スタックレベルがrspecで深すぎます

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を避けるにはどうすればよいですか?

答えて

1

あなたは後に、あなたのコードのバグ、select_reconciliation?方法の最後の行を持っている||あなたはorder_fulfillments_without_receiptsを持っているが、私はあなたが@あなたがorder_fulfillments_without_receiptsメソッドを呼び出している、したがって、無限ループがなければ

@order_fulfillments_without_receiptsを意味だと思います。

の場合はreceipt_urls_empty、コンソールの場合はtrueのいずれの場合も、これはテストではなくコンソールで行われている必要があります。

関連する問題