我正在尝试处理测试控制器,到目前为止,我似乎被困在最简单的问题上。
文档控制器:
def edit
@document = Document.find(params[:id])
end
文档控制器规格:
describe 'GET #edit', focus: true do
before(:each) { @doc = FactoryGirl.create(:document)}
it "should assign @document to the document" do
get :edit, id: @doc
assigns(:document).should eq(@doc)
end
end
总是返回假。@document 总是分配为零。我尝试将 params[id] 指定为 @doc.id,但这并不能解决任何问题。我在这里做错了什么?