0
我運行測試,顯示錯誤。rspec ActiveRecord :: RecordNotFound:無法找到提案'ID'=
失敗:
1)ContractsController POST#創建與有效屬性重定向到支付頁面 故障/錯誤:@proposal = Proposal.find(PARAMS [:PROPOSAL_ID])
ActiveRecord::RecordNotFound:
Couldn't find Proposal with 'id'=
需要' rails_helper」
describe ContractsController do
login_client
describe 'POST #create' do
let(:proposal) { create(:proposal) }
let(:contract) { create(:contract) }
context 'with valid attributes' do
it 'redirects to payment page' do
post :create, contract: attributes_for(:contract)
expect(response).to redirect_to payment_new_path
end
end
end
end
工廠女孩:
FactoryGirl.define do
factory :contract do
sequence(:title) { |n| "translation#{n}" }
amount 150
additional_information 'X' * 500
due_date { 21.days.from_now }
proposal
client
contractor
end
end
FactoryGirl.define do
factory :proposal do
description text
amount 150
project
user
end
end
除了創建資源,還有什麼在你創造的行動會發生什麼? – oreoluwa