Ruby on rails Rspec错误。(找不到使用的询问)

Ruby on rails Rspec错误。(找不到使用的询问),ruby-on-rails,ruby,rspec,Ruby On Rails,Ruby,Rspec,下面是spec/controllers/askings\u controller\u spec.rb require 'rails_helper' RSpec.describe AskingsController, type: :controller do describe 'Get #show' do before do @asking=create(:asking) get :show , id: @asking

下面是spec/controllers/askings\u controller\u spec.rb

   require 'rails_helper'

    RSpec.describe AskingsController, type: :controller do
     describe 'Get #show' do
      before do 
          @asking=create(:asking)
          get :show , id: @asking.id
      end
      it 'should render show' do
          expect(response).to render_template(:show)
      end
      it 'should Undertaking new' do
          expect(assigns(:undertaking)).to be_a_new(Undertaking)
      end
      it 'should response status 200' do
          expect(response.status).to eq(200)
      end
     end
    end
rspec结果如下

     1) AskingsController Get #show should render show
       Failure/Error: @asking=Asking.find(id: params[:id]) 
       ActiveRecord::RecordNotFound:
       Couldn't find Asking with 'id'={:id=>"2"}
    2) AskingsController Get #show should Undertaking new
       Failure/Error: @asking=Asking.find(id: params[:id])     
       ActiveRecord::RecordNotFound:
       Couldn't find Asking with 'id'={:id=>"2"}
   3) AskingsController Get #show should response status 200
      Failure/Error: @asking=create(:asking)    
      ActiveRecord::RecordInvalid:
      mailaddress exists.(<- I translate Japanese error.)
1)AskingsController Get#show应呈现show
失败/错误:@asking=asking.find(id:params[:id])
ActiveRecord::RecordNotFound:
找不到具有'id'={:id=>“2”}的询问
2) 要求控制员出示新的
失败/错误:@asking=asking.find(id:params[:id])
ActiveRecord::RecordNotFound:
找不到具有'id'={:id=>“2”}的询问
3) AskingsController获取#显示应响应状态200
失败/错误:@asking=create(:asking)
ActiveRecord::RecordInvalid:

mailaddress存在。(您可能传递了错误的参数。请尝试
get:show,{{id:@asking.id}}
谢谢您的评论!抱歉,我尝试了您的解决方案,但仍然存在相同的错误。好的,您可以尝试一下吗?
get:show,@asking.id
1)AskingsController get#show应该呈现show失败/错误:get:show,@asking.id NoMethodError:2:FixnumI的未定义方法'key',请参阅,
asking.find(id:params[:id])
应为
asking.find(params[:id])