I am writing a specification for a controller:
it 'should call the method that performs the movies search' do movie = Movie.new movie.should_receive(:search_similar) get :find_similar, {:id => '1'} end
and my controller looks like this:
def find_similar @movies = Movie.find(params[:id]).search_similar end
after running rspec, I get the following:
Failures: 1) MoviesController searching by director name should call the method that performs the movies search Failure/Error: movie.should_receive(:search_similar) (
which I seem to understand and accept, because in my controller code I call the Class (Movie) method and I see no way to associate "find_similar" with the object created in the specification.
So the question is → how to check if a method is called on an object created in spec?
source share