0
브라우저에서 테스트 할 때 작동이 실제로 작동하더라도 테스트에 실패했습니다. 내 시험에 문제가 생겼어.코드가 작동하지만 테스트가 실패합니다.
나는 Shoulda and fixtures를 사용하고 있습니다.
require 'test_helper'
class AddressesControllerTest < ActionController::TestCase
context 'on PUT to :update' do
setup do
put(:update, {
:id => addresses(:mary_publics_address).id,
:street1 => '123 Now St.'
}, { :user_id => users(:stan).id})
end
should 'update the Address' do
a = Address.find(addresses(:mary_publics_address).id)
assert(a.street1 == '123 Now St.', 'Attribute did not get updated.')
end
end
end
"특성이 업데이트되지 않았습니다."와 함께 실패합니다. [: 주소] 당신이 시험에 액션에 전달하는 매개 변수에 지정된
class AddressesController < ApplicationController
def update
@address = Address.find(params[:id])
@address.update_attributes!(params[:address])
render(:text => "Address with ID #{params[:id]} updated")
end
end
"코드는 작동하지만 테스트가 실패합니다". 테스트 팀이 전화 할 때 처음 생각했습니다. P – nik
a.street1은 무엇을 다시 가져 옵니까? – Steven
그냥 내 마지막 댓글을 명확하게; 나는 A.street1이 실제로 무엇이 가정으로 되돌아 오는 지 물어 본다. 테스트를 통해 테스트에서 예상 값과 실제 값을 인쇄하는 것은 매우 통찰력이 있습니다. – Steven