我正在尝试为我的一个控制器上的自定义操作编写请求规范。
我的 routes.rb 是这样的:
resources :cars do
member do
get :search
end
end
我的 cars_controller.rb 是这样的:
class CarsController < ApplicationController
def search
# pending
end
end
我的 controller_cars_spec.rb 是这样的:
describe CarsController do
describe 'Search' do
it 'should call the model method that perform search by brand' do
get :search
end
end
end
耙子路线说:
search_car GET /cars/:id/search(.:format) {:action=>"search", :controller=>"cars"}
和自动测试说:
Failures:
1) CarsController Search should call the model method that perform search by brand
Failure/Error: get :search
ActionController::RoutingError:
No route matches {:controller=>"cars", :action=>"search"}
# ./spec/controllers/cars_controller_spec.rb:19:in `block (3 levels) in <top (required)>'
有什么问题?我无法解决这个失败...