0

我已经设置了一些规范来测试我的活动管理控制器。

it "assigns the requested blog to @blog" do
  @blog = FactoryGirl.create(:blog)
  get :show, id: @blog
  assigns(:blog).should eq(@blog) 
end

当我单独运行这个规范文件时,它都是绿色的,但是当我运行我的所有规范时,我得到了这个错误:

Failure/Error: get :show, :id => @blog
         ActionView::Template::Error:
           No route matches {:id=>#<User id: nil, role: nil, phone: nil, name: nil, firm_id: nil, hourly_rate: nil, loginable_type: nil, loginable_id: nil, loginable_token: nil, created_at: nil, updated_at: nil, avatar_file_name: nil, avatar_content_type: nil, avatar_file_size: nil, avatar_updated_at: nil, email: "", encrypted_password: "", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil, sign_in_count: 0, current_sign_in_at: nil, last_sign_in_at: nil, current_sign_in_ip: nil, last_sign_in_ip: nil>, :controller=>"admin/blogs", :action=>"edit", :format=>nil} missing required keys: [:id]

知道有什么问题吗?

4

0 回答 0