我試圖創建一個路由到一個控制器方法,以便它傳遞一個rpsec條件。出於某種原因,我逃脫了,RSPEC將不接受這條路線。Rails routes,rspec
這裏是RSpec的:
describe BooksController do
describe 'searching AMZN' do
it 'should call the model method that performs AMZN search' do
post :search_tmdb, {:search_terms => 'hardware'}
end
我的路線文件上寫着:
Rottenpotatoes::Application.routes.draw do
resources :books
post '/books/search_amzn'
# map '/' to be a redirect to '/books'
root :to => redirect('/books')
end
在books_controller.rb控制器動作:
def search_amzn
@books = Books.find_in_amzn(params[:search_terms])
end
我清楚地作出一個錯誤我的路線我無法擺脫這個錯誤信息:
1) MoviesController searching AMZN should call the model method that performs AMZN search
Failure/Error: post :search_amzn, {:search_terms => 'hardware'}
ActionController::RoutingError:
No route matches {:search_terms=>"hardware", :controller=>"books", :action=>"search_amzn"}
# ./spec/controllers/books_controller_spec.rb:9:in `block (3 levels) in <top (required)>'
這裏是鏈接到完整的文件:
的routes.rb:http://pastebin.com/yKBeLLnY
規格:http://pastebin.com/cU3nRSvE
'後:search_tmdb'這裏你正在寫'search_tmdb'是什麼這和它的定義在哪裏?你在這裏打電話發佈行動和顯示獲取路線。 :) –
你確定這是導致錯誤的路線? –
@ Dave:除非我錯過了我的知識基礎之外的東西,否則這是違規路線。 – iammurp