2
我一直運行這個錯誤以獲取GET請求以顯示操作。Rspec中的路由錯誤
1) ShopController GET 'show' should be successful
Failure/Error: get 'show', :id=>@shop.user.nickname
ActionController::RoutingError:
No route matches {:id=>"picardo", :controller=>"shop", :action=>"show"}
# ./spec/controllers/shop_controller_spec.rb:8:in `block (3 levels) in <top (required)>'
我的路線是這樣的。
#routes.rb
resources :shop, :only=>[:show]
這是控制器規格:
#shop_controller_spec.rb
before(:each) do
@shop = Fabricate(:shop)
end
describe "GET 'show'" do
it "should be successful" do
get 'show', :id=>@shop.user.nickname
response.should be_success
end
end
而德控制器:
def show
@user = User.find(:first,:conditions=>{:nickname=>params[:id]})
@shop = @user.shop
end
對此有何字?我也有這個最簡單的問題。 –