2012-08-28 30 views
0

我已經通過的位置資源和訪問:RSpec的控制器規格的訪問路線

http://localhost:3000/locations/37/edit 

在我的天賦,我有:

it "should allows us to edit" do 
    @u=User.find_by_email('[email protected]') 
    session[:user_id][email protected]  
    get edit_location_path, {:id => '37'} 

但出現以下錯誤:

Failures: 

    1) LocationsController should allows us to edit 
    Failure/Error: get edit_location_path, :id => '37' 
    ActionController::RoutingError: 
     No route matches {:action=>"edit", :controller=>"locations"} 
    # ./spec/controllers/locations_controller_spec.rb:12:in `block (2 levels) in <top (required)>' 

我將如何指定此資源的鏈接?

THX

+0

看起來你正在丟失路由中的id,它沒有顯示在路由錯誤中(應該有一個':id =>'37')。 –

+0

您可能想要模擬位置模型,並將其傳遞給edit_location_path(location) – BlueFish

回答

1

只是做get edit_location_path(37) ??

+0

thx,我在引起問題的響應中出現語法錯誤 – timpone

2

假設它是描述LocationsController控制器的規格,你可以用get :edit, :id => 37訪問它。

相關問題