diff --git a/app/models/movie.rb b/app/models/movie.rb index 7c58cab68..22ded4821 100644 --- a/app/models/movie.rb +++ b/app/models/movie.rb @@ -10,10 +10,12 @@ def self.find_in_tmdb(string) Tmdb.api_key = self.api_key begin TmdbMovie.find(:title => string) - rescue ArgumentError, RuntimeError - raise Movie::InvalidKeyError + rescue ArgumentError => tmdb_error + raise Movie::InvalidKeyError, tmdb_error.message + end + rescue RuntimeError => tmdb_error + raise Movie::InvalidKeyError, tmdb_error.message end end - # rest of file elided for brevity end diff --git a/spec/controllers/movies_controller_spec.rb b/spec/controllers/movies_controller_spec.rb index 555641e26..4e2d65097 100644 --- a/spec/controllers/movies_controller_spec.rb +++ b/spec/controllers/movies_controller_spec.rb @@ -10,15 +10,17 @@ and_return(@fake_results) post :search_tmdb, {:search_terms => 'hardware'} end - it 'should select the Search Results template for rendering' do - Movie.stub(:find_in_tmdb).and_return(@fake_results) - post :search_tmdb, {:search_terms => 'hardware'} - response.should render_template('search_tmdb') - end - it 'should make the TMDb search results available to that template' do - Movie.stub(:find_in_tmdb).and_return(@fake_results) - post :search_tmdb, {:search_terms => 'hardware'} - assigns(:movies).should == @fake_results + describe 'after valid search' do + before :each do + Movie.stub(:find_in_tmdb).and_return(@fake_results) + post :search_tmdb, {:search_terms => 'hardware'} + end + it 'should select the Search Results template for rendering' do + response.should render_template('search_tmdb') + end + it 'should make the TMDb search results available to that template' do + assigns(:movies).should == @fake_results + end end end end