1
私は宿題をしていますが、私はRestFul以外のルートに問題があります。 私のスペックは次のとおりです。私が持っているのconfig/routes.rbをでRspecルートと非RestFulルート
require 'spec_helper'
describe MoviesController do
describe 'searching TMDb' do
before :each do
@fake_results = [mock('Movie'), mock('Movie')]
end
it 'should call the model method that performs TMDb search' do
Movie.should_receive(:find_in_tmdb).with('Star Wars').
and_return(@fake_results)
get :search_similar_movies, { :search_terms => 'Star Wars' }
end
end
end
:
resources :movies
'movies/search_similar_movies/:search_terms'
しかし、私は自動テストを実行すると、それは私で始まるエラーを与える:
/usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.1.0/lib/action_dispatch/routing/mapper.rb:181:in `default_controller_and_action': missing :action (ArgumentError)
それは明らかです何かが間違っているのはconfig/routes.rbです。これを解決するには?
のようなものでなければなりません。http://guides.rubyonrails.org/routing.html#adding-collection-routesを – pjumble
@pjumble、それは動作します。 param:search_termをルートのどこかに指定する必要はありますか? –