Modeli: payment.rbActiveRecord İlişkiler ile RSpec Pass Model Can not Get
class Payment < ActiveRecord::Base
belongs_to :loan
def self.previous_payments(id)
where(loan_id: id)
end
end
doğru loan_id varsa ben yapmaya çalışıyorum Tüm emin bir ödeme bulunursa yapmak testtir
Testi:
describe '#self.previous_payments' do
let(:loan) {Loan.create!(id: 1, funded_amount: 1000.0)}
let(:payment_one) {Payment.create!(amount: 100.0, loan_id: 1)}
let(:payment_test) {Payment.previous_payments(1)}
it 'retrieves all the payments made for a specific loan' do
expect(payment_test.first.loan_id).to eql(1)
end
end
Ama bu hatayı almaya devam:
expected: 1
got: #<ActiveRecord::Relation []>
Ve [] gibi görünüyor hiçbir kayıt bulunamadı bile demektir?
Her hangi bir yardım çok takdir edilecektir!
Ahhh teşekkürler ton james00794! Mükemmel çalıştı. Asla "let" yerine "let" koyma hakkında hiçbir zaman tahmin edemezdim. – user3007294