Skip to content

Commit

Permalink
made files consistent with end of TDD chapter
Browse files Browse the repository at this point in the history
  • Loading branch information
armandofox committed Oct 29, 2011
1 parent 62f9751 commit 6de90a7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
8 changes: 5 additions & 3 deletions app/models/movie.rb
Expand Up @@ -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
20 changes: 11 additions & 9 deletions spec/controllers/movies_controller_spec.rb
Expand Up @@ -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

0 comments on commit 6de90a7

Please sign in to comment.