I am trying to get instructions for testing controllers, and so far I seem to be sticking to the simplest problems.
documents.controller:
def edit @document = Document.find(params[:id]) end
documents_controller_spec:
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
Always returns false. @document is always assigned nil. I tried to specify params [id] as @ doc.id, but that didnโt fix anything. What am I doing wrong here?
source share