1
모델을 테스트하려하지만 모의 모델을 만드는 데 문제가 있습니다.컨트롤러를 테스트하기 위해 mock_model을 사용하는 데 문제가 있습니다.
Failure/Error: License.should_receive(:all).and_return(mocks)
(<License(id: integer, license_id: string, location: string, format: string, license_type: string, language: string, context: string, licensor: string, licensee: string, resource: string, created_at: datetime, updated_at: datetime) (class)>).all(any args)
expected: 1 time
received: 0 times
: 난 내 RSpec을 실행했을 때 오류가 발생하는, 그러나
it "can show a license" do
mocks = (1..3).map { mock_model(License) }
License.should_receive(:all).and_return(mocks)
post :show, {:id => 1}
:
여기def show
@license = License.find(params[:id])
내 RSpec에의 일부입니다 : 여기
컨트롤러의 일부입니다
또한이 방법을 사용하면 License 개체에있는 ID를 어떻게 변경할 수 있습니까? 'mocks [0] .id = 5'가 작동합니까?
도움이 될 것입니다. 감사.
은 어디에서'License.all'을 수행? –