1
나는 잠시 동안 내 머리를 때리고 있었고 아무런 진전을 이루지 못했습니다. 나는이 작업을 테스트하기 위해 노력하고몽고이드와 RSpec에 대한 ID 문제
def create
@job = Job.new(params[:job])
respond_to do |format|
if @job.save
flash[:notice] = "The Job is ready to be configured"
format.html { redirect_to setup_job_path(@job.id) }
format.json { head :ok }
else
format.html { redirect_to new_job_path, notice: 'There was an error creating the job.' }
format.json { render json: @job.errors, status: :unprocessable_entity }
end
end
end
:
나는 다음과 같은 컨트롤러 액션이있다. 여기 성공적인 제작에 대한 리디렉션 테스트가 있습니다.
let (:job) { mock_model(Job).as_null_object }
나는 다음과 같은 오류가 계속 :
it "redirects to the Job setup" do
job.stub(:id=).with(BSON::ObjectId.new).and_return(job)
job.stub(:save)
post :create
response.should redirect_to(setup_job_path(job.id))
end
작업이 여기에 전체 제품군에 대한 정의되지 않은 상관없이 내가 몇 가지 다른 일을 시도했습니다
2) JobsController POST create when the job saves successfully redirects to the Job setup
Failure/Error: response.should redirect_to(setup_job_path(job.id))
Expected response to be a redirect to <http://test.host/jobs/1005/setup> but was a redirect to <http://test.host/jobs/4ea58505d7beba436f000006/setup>
을하지만 I 시험에서 적절한 객체 ID를 얻지 못하는 것입니다.
고맙습니다! 저는 rspec에 익숙하지 않고 배정 된 것을 잊어 버리는 것 같습니다. – LeakyBucket