Controller spec unknown keyword: id

前端 未结 1 834
别跟我提以往
别跟我提以往 2020-12-01 08:53

I have simple action show

def show
  @field = Field.find_by(params[:id])
end

and i want write spec for it

require \'spec_         


        
1条回答
  •  有刺的猬
    2020-12-01 09:15

    HTTP request methods will accept only the following keyword arguments params, headers, env, xhr, format

    According to the new API, you should use keyword arguments, params in this case:

      it 'should show field' do
        get :show, params: { id: field.id }
        expect(response.status).to eq(200)
      end
    

    0 讨论(0)
提交回复
热议问题