我不断收到这个我无法弄清楚的错误:
Failure/Error: get :find_movies, {:id => @id_passed }
NoMethodError:
undefined method `get' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_1:0x0000000363f800>
对于以下 rspec 测试:
it 'should find the movie in the database by the passed id' do
Movie.should_receive(:find).with(@id_passed).and_return(@movie_found)
get :find_movies, {:id => @id_passed }
end
它使用以下路线:
get '/movies/find/:id' => 'movies#find', :as => :find_movies
我的控制器包括:
def find
@movie = Movie.find params[:id]
if @movie.director != ""
@similar = Movie.where({:director => @movie.director}).all if @movie.director
else
flash[:warning] = "\'#{@movie.title}\' has no director info"
redirect_to movies_path
end
end
我的朋友几乎写了完全相同的代码并让它工作。谁能帮我弄清楚为什么这不起作用?非常感谢!